[R] loop function

fatimah soleimany fatimah.soleimany at gmail.com
Thu Aug 18 13:48:36 CEST 2016


Hi Dear users,
for an interactive use, i am trying to write a loop that looks for all
variables in the conditions which i introduced, this is what I'm trying:

library(MASS)> i=1> for (i in 58:1){+ for(j in 58:i){+ + str.temp <-
paste("y1 ~ x", i, "* x", j, sep = "")+
univar<-glm.nb(as.formula(str.temp), data=df)+
b=summary(univar)$coeffients[4,4]+ b<-c(i,j)+ if(b < 0.6){ +
print(b)+    }+   }+   }

i have no error but i didn't get true response too, my result is this:


b[1] 1 1

 but i want all the variables that their p-value are less than 0.6, i
think i couldn't write a true loop,can you help me?

thank you in advance for any help

	[[alternative HTML version deleted]]



More information about the R-help mailing list