[R] how to modify variables of another frame (but not global)
Henrik Bengtsson
hb at maths.lth.se
Tue Mar 23 12:28:30 CET 2004
Hi, this has recently been discussed r-help. Please search the archive
for more details. The short summary is that you need to use assign()
or the <<- assignment operator depending on your exact problem.
Cheers
Henrik Bengtsson
Lund University
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Meinhard
Ploner
> Sent: den 23 mars 2004 12:18
> To: r-help at stat.math.ethz.ch
> Subject: [R] how to modify variables of another frame (but not
global)
>
>
> Hello!
>
> Maybe "frame" is not the right term in this context.
> I explain my problem by example code:
>
> fun2 <- function(objName, add) {
> ## the object "objName" should be increased by "add",
> ## but the evaluation should be done in the calling
> function (here:
> fun1)
> ## ...... what's the right code??
> }
>
> fun1 <- function() {
> x <- 1
>
> fun2("x", 10) ## should modify "x"
>
> ## now x should be 11, but only here and NOT globally!
> ...
> }
>
>
> I would like to appreciate any solution!
> Thanks in advance
>
> Meinhard Ploner
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailma> n/listinfo/r-help
> PLEASE
> do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
More information about the R-help
mailing list