Re: [R] extracting vectors from lists of lists

2009-12-15 Thread David Winsemius
On Dec 14, 2009, at 11:55 AM, Jennifer Young wrote: This is just the thing. The former version I would never have guessed, but the function(x) version is much more intuitive. Does there exist some section of some manual where these sorts of things are explained? I find that figuring out

Re: [R] extracting vectors from lists of lists

2009-12-14 Thread Jennifer Young
This is just the thing. The former version I would never have guessed, but the function(x) version is much more intuitive. Does there exist some section of some manual where these sorts of things are explained? I find that figuring out how to access parts of output is the trickiest thing in R.

[R] extracting vectors from lists of lists

2009-12-11 Thread Jennifer Young
Good evening I often have as output from simulations a list of various values, vectors and matrices. Supposing that I then run said simulation several times, I often want to extract a particular result from each simulation for plotting and, ideally, put it in a matrix. A simple example v1 - 1:5

Re: [R] extracting vectors from lists of lists

2009-12-11 Thread Phil Spector
Jennifer - Does this do what you want? v1 = sapply(output,'[[','vec') v2 = sapply(output,'[[','other') v1 [,1] [,2] [1,]16 [2,]27 [3,]38 [4,]49 [5,]5 10 v2 [1] stuff stuff (in more readable form: v1 = sapply(output,function(x)x$vec) v2 =

Re: [R] extracting vectors from lists of lists

2009-12-11 Thread Benilton Carvalho
oh.. and i just saw the bonus part... just replace lapply() by sapply(). b On Dec 11, 2009, at 8:33 PM, Jennifer Young wrote: Good evening I often have as output from simulations a list of various values, vectors and matrices. Supposing that I then run said simulation several times, I

Re: [R] extracting vectors from lists of lists

2009-12-11 Thread David Winsemius
On Dec 11, 2009, at 5:33 PM, Jennifer Young wrote: Good evening I often have as output from simulations a list of various values, vectors and matrices. Supposing that I then run said simulation several times, I often want to extract a particular result from each simulation for plotting