Skip to content

Select components of a list

1 message · arun

#
Hi Gustav,

Try this:

lapply(1:length(models),function(i) lapply(models[[i]],function(x) summary(x)$coef[2,]))[[1]] #1st list component
[[1]]
#??? Estimate?? Std. Error????? z value???? Pr(>|z|) # pm10
#5.999185e-04 1.486195e-04 4.036606e+00 5.423004e-05 

#[[2]]
#??? Estimate?? Std. Error????? z value???? Pr(>|z|) #ozone
#0.0010117294 0.0003792739 2.6675428048 0.0076408155 

#[[3]]
#??? Estimate?? Std. Error????? z value???? Pr(>|z|) #so2
#0.0026595441 0.0009352046 2.8438097399 0.0044577658 

#pm10
do.call(rbind,lapply(1:length(models),function(i) do.call(rbind,lapply(models[[i]],function(x) summary(x)$coef[row.names(summary(x)$coef)=="pm10",c(1:2,4)]))))
#???????? Estimate?? Std. Error???? Pr(>|z|)
#[1,] 0.0005999185 0.0001486195 5.423004e-05
#[2,] 0.0005720549 0.0001740368 1.012696e-03
#[3,] 0.0005099552 0.0001559620 1.076462e-03
#[4,] 0.0009285593 0.0001766520 1.468764e-07

#ozone

?do.call(rbind,lapply(1:length(models),function(i) do.call(rbind,lapply(models[[i]],function(x) summary(x)$coef[row.names(summary(x)$coef)=="ozone",c(1:2,4)]))))
?# ?????? Estimate?? Std. Error???? Pr(>|z|)
#[1,] 0.0010117294 0.0003792739 7.640816e-03
#[2,] 0.0009128304 0.0004364390 3.647954e-02
#[3,] 0.0023896044 0.0004109854 6.087769e-09
#[4,] 0.0005455392 0.0004301502 2.047076e-01
#so2 

do.call(rbind,lapply(1:length(models),function(i) do.call(rbind,lapply(models[[i]],function(x) summary(x)$coef[row.names(summary(x)$coef)=="so2",c(1:2,4)])))) 
#??????? Estimate?? Std. Error??? Pr(>|z|)
#[1,] 0.002659544 0.0009352046 0.004457766
#[2,] 0.002825612 0.0010150314 0.005373144
#[3,] 0.002409738 0.0009563814 0.011747444
#[4,] 0.001725140 0.0011635156 0.138155175



Hope it helps.
A.K.