I'm trying to build a for loop with an if statement in order to obtain a list of relevant models (single parameter linear models). I have a list of lm summaries. I would like to create a list of all the models with Pr(>|t|) smaller than 0.05. Here is my best attempt, the if statement
Error in if (z < 0.25) { : missing value where TRUE/FALSE needed
Here is my code: (listX is a list of models)
a<-list()
for (i in length(ListX)){
if((coef(ListX[[i]]))[2,4]<0.05){
b<-coef(ListX[[i]])[2,4]
a<-c(a,b)
}
}
coef(ListX[[1]]))[2,4] gives the "Pr(>|t|)" of the coefficient in that lm
Any help would be much appreciated.
Aucun commentaire:
Enregistrer un commentaire