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
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.
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
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 =
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
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
6 matches
Mail list logo