Re: [R] Defining multiple variables in a loop

2012-06-24 Thread Berend Hasselman
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 fo

Re: [R] Defining multiple variables in a loop

2012-06-24 Thread Jorge I Velez
Please use split() instead of strsplit(). Apologies to all. --JIV On Sun, Jun 24, 2012 at 11:38 PM, Jorge I Velez <> wrote: > Dear Taylor, > > You might also try > > with(OECDFiscal2, strsplit(OECDFical2, Country)) > > HTH, > Jorge.- > > > > On Sun, Jun 24, 2012 at 11:31 PM, Taylor White <> wr

Re: [R] Defining multiple variables in a loop

2012-06-24 Thread Jorge I Velez
Dear Taylor, You might also try with(OECDFiscal2, strsplit(OECDFical2, Country)) HTH, Jorge.- On Sun, Jun 24, 2012 at 11:31 PM, Taylor White <> wrote: > Thank you gentlemen for pointing me in the right direction. > > This code worked nicely: > > > countries <- list() > > for (i in 1:20) { > c

Re: [R] Defining multiple variables in a loop

2012-06-24 Thread Joshua Wiley
Hi Taylor, Even clearner would be: countries <- lapply(1:20, function(i) as.matrix(subset(OECDFiscal2, Country == i))) if you prefer to stick with the loop (up to you), I would instantiate the list at size: countries <- vector("list", 20) for (i in 1:20) { countries[[i]] = as.matrix(subset(O

Re: [R] Defining multiple variables in a loop

2012-06-24 Thread Taylor White
Thank you gentlemen for pointing me in the right direction. This code worked nicely: countries <- list() for (i in 1:20) { countries[[i]] = as.matrix(subset(OECDFiscal2, Country == i)) } Take care, Taylor On Sun, Jun 24, 2012 at 3:01 PM, R. Michael Weylandt wrote: > To elaborate on what Ber

Re: [R] Defining multiple variables in a loop

2012-06-24 Thread R. Michael Weylandt
To elaborate on what Bert said: Lists are a variable length data structure which can hold most anything (even other lists) in them and are a great way to organize the sort of data you're working with. You can think of them as "generic vectors." You can assign them names and access/subset them by n

Re: [R] Defining multiple variables in a loop

2012-06-24 Thread Bert Gunter
Standard response: Use lists instead. Read An Intro to R to learn about lists. In fact,read an An Intro to R, full stop ( if you have not already done so). Cheers, Bert On Sun, Jun 24, 2012 at 2:15 PM, Taylor White wrote: > Good day, > > For lack of a better solution (or perhaps I am ignorant t

[R] Defining multiple variables in a loop

2012-06-24 Thread Taylor White
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