Re: [R] Create variable by name

2010-10-06 Thread Ralf B
Hi all, I have scripts that have one variable called 'output', the script creates a data frame and stores this data frame in 'output'. Then the data frame is written to disk. This is simple when working with a single script. However, as soon as one script calls other, variables overwrite each othe

Re: [R] Create variable by name

2010-10-06 Thread Greg Snow
Possible? Yes (as others have shown), advisable? No, see fortune(106), fortune(236), and possibly fortune(181). What is your ultimate goal? Maybe we can help you find a better way. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111

Re: [R] Create variable by name

2010-10-06 Thread David Winsemius
On Oct 6, 2010, at 12:58 PM, David Winsemius wrote: On Oct 6, 2010, at 12:32 PM, Ralf B wrote: Can one create a variable through a function by name Isn't that what "<-" does? createVariable <- function(name) { outputVariable = name name <- NULL } after calling createVa

Re: [R] Create variable by name

2010-10-06 Thread David Winsemius
On Oct 6, 2010, at 12:32 PM, Ralf B wrote: Can one create a variable through a function by name Isn't that what "<-" does? createVariable <- function(name) { outputVariable = name name <- NULL } after calling createVariable("myVar") ?assign # and isn't this covered in

Re: [R] Create variable by name

2010-10-06 Thread Jeffrey Spies
An alternative to Peter's solution: createVariable <- function(name) {assign(name, NULL, envir=.GlobalEnv)} Jeff. On Wed, Oct 6, 2010 at 12:32 PM, Ralf B wrote: > Can one create a variable through a function by name > > createVariable <- function(name) { >        outputVariable = name >        

Re: [R] Create variable by name

2010-10-06 Thread Peter Langfelder
On Wed, Oct 6, 2010 at 9:32 AM, Ralf B wrote: > Can one create a variable through a function by name > > createVariable <- function(name) { >        outputVariable = name >        name <- NULL > } > > after calling > > createVariable("myVar") > > I would like to have a variable myVar initialized w

Re: [R] Create variable by name

2010-10-06 Thread Peter Langfelder
On Wed, Oct 6, 2010 at 9:32 AM, Ralf B wrote: > Can one create a variable through a function by name > > createVariable <- function(name) { >        outputVariable = name >        name <- NULL > } > > after calling > > createVariable("myVar") > > I would like to have a variable myVar initialized w