Re: [R] Create variable by name

2010-10-06 Thread Ralf B
e- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of Ralf B >> Sent: Wednesday, October 06, 2010 10:32 AM >> To: r-help Mailing List >> Subject: [R] Create variable by name >> >> Can one create a variable thro

Re: [R] Create variable by name

2010-10-06 Thread Greg Snow
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Ralf B > Sent: Wednesday, October 06, 2010 10:32 AM > To: r-help Mailing List > Subject: [R] Create variable by name > > Can one create a variable th

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

[R] Create variable by name

2010-10-06 Thread Ralf B
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 with NULL in my environment. Is this possible? Ralf