Thank you so much, relist and SIMPLIFY both work.

See more comments below ...

On 10/12/2009 5:35 PM, Charles C. Berry wrote:
On Mon, 12 Oct 2009, Magnus Torfason wrote:
I want to achieve the following:

 l <- list( list(a=1,b=2), list(a=3,b=4))
 l[[]]["a"] <- 5:6
>
See
    ?relist

something like:

    relist( unlist( mapply( "[<-", l, "a", 5:6) ), l )

Yes, this works exactly as needed. I had tried this, but I failed to notice that you could supply the skeleton argument separately. Thanks!

I had also tried

    mapply( "[<-", l, "a", c(5,6), SIMPLIFY=FALSE)

but failed to put SIMPLIFY in all-caps, and got an error message that I did not understand. It seems I was close on both methods, but not close enough.

Best,
Magnus

______________________________________________
R-help@r-project.org 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.

Reply via email to