Re: [R] Assigning variables using a loop

2011-04-23 Thread Nick Mosely
Thank you for your help. That works for me. On Sat, Apr 23, 2011 at 1:53 PM, Joshua Wiley wrote: > Hi Nick, > > It is typically not a good idea to write functions that automatically > assign variables to the global environment (makes it easy to overwrite > something valuable without knowing you a

Re: [R] Assigning variables using a loop

2011-04-23 Thread Joshua Wiley
Hi Nick, It is typically not a good idea to write functions that automatically assign variables to the global environment (makes it easy to overwrite something valuable without knowing you are overwriting it), but if that is really the best choice for your situation, I would do something like (ins

[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