[R] function changes argument
Moeltner, Andreas
Andreas.Moeltner at med.uni-heidelberg.de
Mon Sep 11 10:49:26 CEST 2006
Dear R-list,
the following function f changes L. I thought, assignments within
functions are only local?
f<-function(LL)
{ for (ll in LL)
{ ll$txt<-"changed in f"
}
}
l<-list(txt="original value")
L<-list(l)
L[[1]]$txt
f(L)
L[[1]]$txt
gives (using R 2.3.1):
...
> L[[1]]$txt
[1] "original value"
> f(L)
> L[[1]]$txt
[1] "changed in f"
>
Thanks in advance
Andreas
More information about the R-help
mailing list