Taylor White wrote > > Good day, > > For lack of a better solution (or perhaps I am ignorant to something > more elegant), I have been bootstrapping panel data by hand so to > speak and I would like to know if there is a way to define multiple > variables in a loop using the loop variable. I found a post (here: > https://stat.ethz.ch/pipermail/r-help/2002-October/026305.html ) that > discussed naming multiple variables but it didn't seem to allow me to > define the variables as something more useful. I tried the code > immediately below (plus some variations) and it just didn't work. > > for (i in 1:20) { > assign(paste("country.", i, sep = "") <- subset(OECDFiscal2, Country == i) > } >
Leaving aside the question whether this is a good way of doing what you want, this is the wrong syntax. ?assign will show you the correct syntax. assign(paste("country.", i, sep = "") , subset(OECDFiscal2, Country == i)) Berend -- View this message in context: http://r.789695.n4.nabble.com/Defining-multiple-variables-in-a-loop-tp4634361p4634387.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.