On Mon, 11 Sep 2006, Peter Dalgaard wrote:
> [EMAIL PROTECTED] writes:
>
> > I can tell you where the problem is and a workaround:
> >
> > f <- function(LL) for (ll in names(LL)) LL[[ll]]$txt<-"changed in f"
> >
> > works. The problem is that for() is directly exposing the elements of a
> > l
[EMAIL PROTECTED] writes:
> I can tell you where the problem is and a workaround:
>
> f <- function(LL) for (ll in names(LL)) LL[[ll]]$txt<-"changed in f"
>
> works. The problem is that for() is directly exposing the elements of a
> list.
>
> Of course, a more idiomatic construction would be
I can tell you where the problem is and a workaround:
f <- function(LL) for (ll in names(LL)) LL[[ll]]$txt<-"changed in f"
works. The problem is that for() is directly exposing the elements of a
list.
Of course, a more idiomatic construction would be
LL <- lapply(LL, function(x) x$txt <- "cha
I can tell you where the problem is and a workaround:
f <- function(LL) for (ll in names(LL)) LL[[ll]]$txt<-"changed in f"
works. The problem is that for() is directly exposing the elements of a
list.
Of course, a more idiomatic construction would be
LL <- lapply(LL, function(x) x$txt <- "cha
(This report appeared in R-help. I've sent it separately to the bugs
list to avoid a long string of cross-postings.)
On 9/11/2006 4:49 AM, Moeltner, Andreas wrote:
> Dear R-list,
>
> the following function f changes L. I thought, assignments within
> functions are only local?
That looks like a