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]]
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]]
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?... Nom : non disponible URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20130219/55fdad68/attachment.pl>
On 18.02.2013 13:39, Jamora, Nelissa wrote:> 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?help("for") Uwe Ligges> I 'tried' understanding the package.foreach but can't get it to work. > > > > Thanks for any help > > Nelissa > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >