Hi! I'm a recent convert from Stata, so forgive my ignorance.

 

In Stata, I can write foreach loops (example below)

 

foreach var of varlist p1-p14 {

foreach y of varlist p15-p269 {

  reg `var' `y'

}

}

 

It's looping p1-p15, p1-p16...., p1-p269, p2-p15, p2-p16,... p2-p269,...
variable pairs.

 

How can I write something similar in R? 

I 'tried' understanding the package.foreach but can't get it to work.

 

Thanks for any help

Nelissa


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to