Re: [R] Assigning variables using a loop

2011-04-23 Thread Nick Mosely
n(x) { >  assign(x, mydata[[x]], pos = .GlobalEnv) > }) > > HTH, > > Josh > > On Sat, Apr 23, 2011 at 10:51 AM, Nick Mosely wrote: >> Hello R-world, >> >> I have multiple variables that have been generated within a function. >> I would like to assig

[R] Assigning variables using a loop

2011-04-23 Thread Nick Mosely
Hello R-world, I have multiple variables that have been generated within a function. I would like to assign them each to the Global Environment. I've tried the following: x = 1 y = 2 z = 3 for (i in c(x,y,z)) { assign("i",i,pos=.GlobalEnv) } i [1] 3 Obviously, the problem is that the code is a