Re: [R] lapply / mapply and assignments

2009-10-13 Thread Magnus Torfason
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

[R] lapply / mapply and assignments

2009-10-12 Thread Magnus Torfason
I have a list of isometric structures, and I want to change the same part of each structure in the list, assigning one element of a vector to each of these parts. In other words, I want to achieve the following: l - list( list(a=1,b=2), list(a=3,b=4)) unlist(lapply(l, [[, a)) [1] 1 3 #

Re: [R] lapply / mapply and assignments

2009-10-12 Thread Charles C. Berry
On Mon, 12 Oct 2009, Magnus Torfason wrote: I have a list of isometric structures, and I want to change the same part of each structure in the list, assigning one element of a vector to each of these parts. In other words, I want to achieve the following: l - list( list(a=1,b=2),

Re: [R] lapply / mapply and assignments

2009-10-12 Thread Charles C. Berry
Hmmm, after thinking about it, better see ?mapply SIMPLIFY logical; attempt to reduce the result to a vector or matrix? Try mapply( ..., SIMPLIFY=FALSE ) HTH, Chuck On Mon, 12 Oct 2009, Magnus Torfason wrote: I have a list of isometric structures, and I

Re: [R] lapply / mapply and assignments

2009-10-12 Thread Gabor Grothendieck
Try: mapply(..., SIMPLIFY = FALSE) On Mon, Oct 12, 2009 at 5:25 PM, Magnus Torfason zulutime@gmail.com wrote: I have a list of isometric structures, and I want to change the same part of each structure in the list, assigning one element of a vector to each of these parts. In other