Skip to content

Extracting multiple elements from a list

2 messages · Liaw, Andy, Brian Ripley

#
Aren't sapply()/lapply() sufficient for this?
[,1] [,2]
[1,]    1    5
[2,]    2    6
[3,]    3    7
[4,]    4    8
[[1]]
[1] 1 2 3 4

[[2]]
[1] 5 6 7 8

HTH,
Andy
------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}
#
[] works on a list and extracts multiple elements.  However, that is not 
it seems what you want, rather, unions of elements of elements of lists.
That is a pretty unusual need, and perhaps you could explain you you need 
it.

Andy's solution still need something like

do.call("c",  lapply(alist, function(x) x$vec))

but then it *is* unions of elements of elements of lists.
On Thu, 15 Jan 2004, Liaw, Andy wrote: