[R] function changes argument

From: Moeltner, Andreas <Andreas.Moeltner_at_med.uni-heidelberg.de>
Date: Mon 11 Sep 2006 - 08:49:26 GMT

Dear R-list,

the following function f changes L. I thought, assignments within functions are only local?

{ for (ll in LL)
  { ll$txt<-"changed in f"

l<-list(txt="original value")

gives (using R 2.3.1):

> L[[1]]$txt

[1] "original value"
> f(L)
> L[[1]]$txt

[1] "changed in f"

Thanks in advance


R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon Sep 11 18:54:05 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 11 Sep 2006 - 12:30:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.