Hello All:
This function obviously fails
x <- function(z) paste("go", z, sep = ".") <- 10
x("now")
But is there a way to define the name of a variable through passing a
parameter in a function call?
Thanks,
ANDREW
Hallo!
?assign
z<-"now"
assign(paste("go", z, sep = ".") ,10)
Sincerely
Eryk
*********** REPLY SEPARATOR ***********
On 7/11/2004 at 10:02 PM Andrew R. Criswell wrote:
>>>Hello All:
>>>
>>>This function obviously fails
>>>
>>> x <- function(z) <- 10
>>> x("now")
>>>
>>>But is there a way to define the name of a variable through passing
a
>>>parameter in a function call?
>>>
>>>Thanks,
>>>ANDREW
>>>
>>>______________________________________________
>>>R-help at stat.math.ethz.ch mailing list
>>>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
Dipl. bio-chem. Eryk Witold Wolski @ MPI-Moleculare Genetic
Ihnestrasse 63-73 14195 Berlin 'v'
tel: 0049-30-83875219 / \
mail: wolski at molgen.mpg.de ---W-W----
http://www.molgen.mpg.de/~wolski
On Sun, 11 Jul 2004, Andrew R. Criswell wrote:> Hello All: > > This function obviously fails > > x <- function(z) paste("go", z, sep = ".") <- 10 > x("now") > > But is there a way to define the name of a variable through passing a > parameter in a function call?I'm not exactly sure what you want to do, but looking at ?assign might be of some help. Z> Thanks, > ANDREW > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
Wolski <wolski <at> molgen.mpg.de> writes:> > Hallo! > ?assign > > z<-"now" > assign(paste("go", z, sep = ".") ,10)Assuming that you wish to create a variable called go.now with the value of 10 in the caller environment to f: R> f <- function(z) assign(paste("go", z, sep = "."), 10, parent.frame()) R> f("now") R> go.now [1] 10