[R] Extract values from multiple lists
SH
emptican at gmail.com
Tue Dec 16 18:06:05 CET 2014
Dear List,
I hope this posting is not redundant. I have several list outputs with the
same components. I ran a function with three different scenarios below
(e.g., scen1, scen2, and scen3,...,scenN). I would like to extract the
same components and group them as a data frame. For example,
pop.inf.r1 <- scen1[['pop.inf.r']]
pop.inf.r2 <- scen2[['pop.inf.r']]
pop.inf.r3 <- scen3[['pop.inf.r']]
...
pop.inf.rN<-scenN[['pop.inf.r']]
new.df <- data.frame(pop.inf.r1, pop.inf.r2, pop.inf.r3,...,pop.inf.rN)
My final output would be 'new.df'. Could you help me how I can do that
efficiently?
Thanks in advance,
Steve
P.S.: Below are some examples of summary outputs.
> summary(scen1)
Length Class Mode
aql 1 -none- numeric
rql 1 -none- numeric
alpha 1 -none- numeric
beta 1 -none- numeric
n.sim 1 -none- numeric
N 1 -none- numeric
n.sample 1 -none- numeric
n.acc 1 -none- numeric
lot.inf.r 1 -none- numeric
pop.inf.n 2000 -none- list
pop.inf.r 2000 -none- list
pop.decision.t1 2000 -none- list
pop.decision.t2 2000 -none- list
sp.inf.n 2000 -none- list
sp.inf.r 2000 -none- list
sp.decision 2000 -none- list
> summary(scen2)
Length Class Mode
aql 1 -none- numeric
rql 1 -none- numeric
alpha 1 -none- numeric
beta 1 -none- numeric
n.sim 1 -none- numeric
N 1 -none- numeric
n.sample 1 -none- numeric
n.acc 1 -none- numeric
lot.inf.r 1 -none- numeric
pop.inf.n 2000 -none- list
pop.inf.r 2000 -none- list
pop.decision.t1 2000 -none- list
pop.decision.t2 2000 -none- list
sp.inf.n 2000 -none- list
sp.inf.r 2000 -none- list
sp.decision 2000 -none- list
> summary(scen3)
Length Class Mode
aql 1 -none- numeric
rql 1 -none- numeric
alpha 1 -none- numeric
beta 1 -none- numeric
n.sim 1 -none- numeric
N 1 -none- numeric
n.sample 1 -none- numeric
n.acc 1 -none- numeric
lot.inf.r 1 -none- numeric
pop.inf.n 2000 -none- list
pop.inf.r 2000 -none- list
pop.decision.t1 2000 -none- list
pop.decision.t2 2000 -none- list
sp.inf.n 2000 -none- list
sp.inf.r 2000 -none- list
sp.decision 2000 -none- list
[[alternative HTML version deleted]]
More information about the R-help
mailing list