Select components of a list

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Select components of a list

Lungo
This post has NOT been accepted by the mailing list yet.
I have a list which has components that look like this:
> summary(results)
      Length Class  Mode
 [1,] 3      -none- list
 [2,] 3      -none- list
 [3,] 3      -none- list
 [4,] 3      -none- list
 [5,] 3      -none- list
 [6,] 3      -none- list
 [7,] 3      -none- list
 [8,] 3      -none- list
 [9,] 3      -none- list
[10,] 3      -none- list
[11,] 3      -none- list
[12,] 3      -none- list

I could access the summary estimates for the 7th element and 3rd  regressor and obtain this:
 > summary(results[[7]][[3]])

Parametric coefficients:
                Estimate Std. Error t value Pr(>|t|)    
(Intercept)     3.509314   0.032628  107.55   <2e-16 ***
Ozone_L01        0.007228   0.004201    1.72    0.086 .  
as.factor(dow)1 0.018687   0.016470    1.13    0.257    
as.factor(dow)2 0.039073   0.016417    2.38    0.017 *  
as.factor(dow)3 0.000452   0.016637    0.03    0.978    
as.factor(dow)4 0.012638   0.016562    0.76    0.446    
as.factor(dow)5 0.012784   0.016525    0.77    0.439    
as.factor(dow)6 0.010635   0.016477    0.65    0.519    


My wish is to extract the estimates for the second placed element  in the models (in this example I want to extract estimates for Ozone_L01 with corresponding Std. Error and pvalue). How could I do that for the entire list?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Select components of a list

arun kirshna
This post has NOT been accepted by the mailing list yet.
Hi,
Assuming that your list is similar to this (didn't see any 'reproducible example)
set.seed(148)
 x<- runif(100)
 y<- data.frame(y1=5+1.5*x+rnorm(100), y2= 8+0.5*x+rnorm(100), y3= 2.5+0.08*x+rnorm(100))
res<-lapply(names(y),function(i) lm(y[,i]~x))
lapply(res,function(x) summary(x)$coef)
#[[1]]
  #          Estimate Std. Error   t value     Pr(>|t|)
#(Intercept) 4.811968  0.1905163 25.257506 1.072355e-44
#x           1.755122  0.3288810  5.336647 6.111455e-07

#[[2]]
  #           Estimate Std. Error   t value     Pr(>|t|)
#(Intercept) 8.1654826  0.1835681 44.482031 8.605307e-67
#x           0.3235074  0.3168865  1.020893 3.098186e-01

#[[3]]
  #             Estimate Std. Error    t value     Pr(>|t|)
#(Intercept)  2.65369426  0.1928242 13.7622484 1.252616e-24
#x           -0.05232022  0.3328649 -0.1571815 8.754252e-01

#to select a particular row

lapply(res,function(x) summary(x)$coef["(Intercept)",])
#[[1]]
  #  Estimate   Std. Error      t value     Pr(>|t|)
#4.811968e+00 1.905163e-01 2.525751e+01 1.072355e-44

#[[2]]
  #  Estimate   Std. Error      t value     Pr(>|t|)
#8.165483e+00 1.835681e-01 4.448203e+01 8.605307e-67

#[[3]]
#    Estimate   Std. Error      t value     Pr(>|t|)
#2.653694e+00 1.928242e-01 1.376225e+01 1.252616e-24
# if you want only Std. Error and p-value
lapply(res,function(x) summary(x)$coef["(Intercept)",c(2,4)])
[[1]]
#  Std. Error     Pr(>|t|)
#1.905163e-01 1.072355e-44

#[[2]]
 # Std. Error     Pr(>|t|)
#1.835681e-01 8.605307e-67

#[[3]]
 # Std. Error     Pr(>|t|)
#1.928242e-01 1.252616e-24

Hope it helps.
A.K.

Reply | Threaded
Open this post in threaded view
|

Re: Select components of a list

Lungo
This post has NOT been accepted by the mailing list yet.
Dear Arun,  Your code and the example works fine. However my list is quite different from the one showed in your example.   As I have shown in my question above I have 12 lists each having 3 lists underneath.  I get the lists by different models (GLM, GAM ) but the output  I aim to have is the estimates of the explanatory variable which is placed next to the intercept.  Thus I am looking for a “generic” tool that would extract these lists.
Reply | Threaded
Open this post in threaded view
|

Re: Select components of a list

arun kirshna
In reply to this post by Lungo
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.
________________________________
From: Gustav Sigtuna <[hidden email]>
To: arun <[hidden email]>
Sent: Saturday, February 16, 2013 7:44 PM
Subject: Re: Select components of a list


Hi Arun,

Thanks for taking your time to find a solution.

I have attached a R script that will recreate a comparable list from publicly available data. My list is longer and created by various models  than the one created here. However, the final output is similar to the one produced by script. My interest is to extract only the coefficients for  pm10., ozone and so2 (  Estimate,  Std. Error  and p value)    . 

Thanks






On Fri, Feb 15, 2013 at 9:04 PM, arun <[hidden email]> wrote:

Dear Gustav,

>Thank you for the data.  Could you select a smaller subset of the list and dput() that subset?  Your data is useful, but I would have to recreate list of lists from that to test and sometimes that may not accurate represent the format in your list as it is the summary().
>Arun
>
>
>
>
>
>
>
>________________________________
>From: Gustav Sigtuna <[hidden email]>
>To: [hidden email]
>Sent: Friday, February 15, 2013 4:56 AM
>Subject: Re: Select components of a list
>
>
>
>Hi Arun,
>
>Thanks for your help. Your mail landed in my spam folder and just saw it by chance.
>
>I have attached a text file that contains the list of my model. It was extremely long, thus I took out the last part which is think is more important.
>
>
>In brief I have an output from GAM model which resulted from analysis of  ozone at three time points on 12 data sets
>
>Thanks for your assistance
>
>
>
>
>
>On Wed, Feb 13, 2013 at 8:21 PM, <[hidden email]> wrote:
>
>Dear Lungo,
>>
>>If you can email ([hidden email]) me the `list` (dput(list)), I can take a look at it.  Probably, you understand that my previous solution was just guesswork. With regards to GLM, GAM, it is good to check the structure of the list (str()). It gives information about whether a `generic` tool could be applied to extract them or not.
>>Cheers.
>>Arun
>>
>><quote author='Lungo'>
>>Dear Arun,  Your code and the example works fine. However my list is quite
>>different from the one showed in your example.   As I have shown in my
>>question above I have 12 lists each having 3 lists underneath.  I get the
>>lists by different models (GLM, GAM ) but the output  I aim to have is the
>>estimates of the explanatory variable which is placed next to the intercept.
>>Thus I am looking for a “generic” tool that would extract these lists.
>></quote>
>>Quoted from:
>>http://r.789695.n4.nabble.com/Select-components-of-a-list-tp4658295p4658389.html
>> 
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Select components of a list

arun kirshna
In reply to this post by Lungo
HI Gustav,

If you need the combined output:
res<-lapply(1:length(models),function(i) do.call(rbind,lapply(models[[i]],function(x) summary(x)$coef[row.names(summary(x)$coef)%in%c("pm10","ozone","so2"),c(1:2,4)])))
 names(res)<-1:length(res)
res1<-do.call(rbind,lapply(res,function(i) {row.names(i)<-c("pm10","ozone","so2");data.frame(i)}))
names(res1)[2:3]<- c("Std.Error","Pr(>|z|)")
res1
#            Estimate    Std.Error     Pr(>|z|)
#1.pm10  0.0005999185 0.0001486195 5.423004e-05
#1.ozone 0.0010117294 0.0003792739 7.640816e-03
#1.so2   0.0026595441 0.0009352046 4.457766e-03
#2.pm10  0.0005720549 0.0001740368 1.012696e-03
#2.ozone 0.0009128304 0.0004364390 3.647954e-02
#2.so2   0.0028256121 0.0010150314 5.373144e-03
#3.pm10  0.0005099552 0.0001559620 1.076462e-03
#3.ozone 0.0023896044 0.0004109854 6.087769e-09
#3.so2   0.0024097381 0.0009563814 1.174744e-02
#4.pm10  0.0009285593 0.0001766520 1.468764e-07
#4.ozone 0.0005455392 0.0004301502 2.047076e-01
#4.so2   0.0017251400 0.0011635156 1.381552e-01
A.K.






________________________________
From: Gustav Sigtuna <[hidden email]>
To: arun <[hidden email]>
Sent: Saturday, February 16, 2013 7:44 PM
Subject: Re: Select components of a list


Hi Arun,

Thanks for taking your time to find a solution.

I have attached a R script that will recreate a comparable list from publicly available data. My list is longer and created by various models  than the one created here. However, the final output is similar to the one produced by script. My interest is to extract only the coefficients for  pm10., ozone and so2 (  Estimate,  Std. Error  and p value)    . 

Thanks






On Fri, Feb 15, 2013 at 9:04 PM, arun <[hidden email]> wrote:

Dear Gustav,

>Thank you for the data.  Could you select a smaller subset of the list and dput() that subset?  Your data is useful, but I would have to recreate list of lists from that to test and sometimes that may not accurate represent the format in your list as it is the summary().
>Arun
>
>
>
>
>
>
>
>________________________________
>From: Gustav Sigtuna <[hidden email]>
>To: [hidden email]
>Sent: Friday, February 15, 2013 4:56 AM
>Subject: Re: Select components of a list
>
>
>
>Hi Arun,
>
>Thanks for your help. Your mail landed in my spam folder and just saw it by chance.
>
>I have attached a text file that contains the list of my model. It was extremely long, thus I took out the last part which is think is more important.
>
>
>In brief I have an output from GAM model which resulted from analysis of  ozone at three time points on 12 data sets
>
>Thanks for your assistance
>
>
>
>
>
>On Wed, Feb 13, 2013 at 8:21 PM, <[hidden email]> wrote:
>
>Dear Lungo,
>>
>>If you can email ([hidden email]) me the `list` (dput(list)), I can take a look at it.  Probably, you understand that my previous solution was just guesswork. With regards to GLM, GAM, it is good to check the structure of the list (str()). It gives information about whether a `generic` tool could be applied to extract them or not.
>>Cheers.
>>Arun
>>
>><quote author='Lungo'>
>>Dear Arun,  Your code and the example works fine. However my list is quite
>>different from the one showed in your example.   As I have shown in my
>>question above I have 12 lists each having 3 lists underneath.  I get the
>>lists by different models (GLM, GAM ) but the output  I aim to have is the
>>estimates of the explanatory variable which is placed next to the intercept.
>>Thus I am looking for a “generic” tool that would extract these lists.
>></quote>
>>Quoted from:
>>http://r.789695.n4.nabble.com/Select-components-of-a-list-tp4658295p4658389.html
>> 
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Select components of a list

arun kirshna
Hi Gustav,
Just change `summary(x)$coef` to `summary(x)$p.table`
I am pasting the code from the attachment.

library(gamair) 
library(mgcv)
data(chicago) 
library(splines)
 
chicago$date<-seq(from=as.Date("1987-01-01"), to=as.Date("2000-12-31"),length=5114)
 
chicago$trend<-seq(dim(chicago)[1]) 
names(chicago) [2] <-"pm10"
names(chicago) [3] <-"pm25"
names(chicago) [4] <-"ozone"
names(chicago) [5] <-"so2"
names(chicago) [7]   <-"temp"
 
chicago$trend<-seq(dim(chicago)[1])
chicago$year<-as.numeric(format(chicago$date,"%Y")) 
chicago1<-subset(chicago, as.Date(date) < '1999-01-01') 
year<- matrix(1987:1998, ncol=3, byrow=TRUE)

fun <- 
  function( y , x ){
    a <- gam(
      death ~ pm10 + s(trend,k=35) , poisson , na.action = na.omit , data = x[ x$year %in% y , ]
    )
    b<- gam(
      death ~ ozone + s(trend,k=35), poisson , na.action = na.omit , data = x[ x$year %in% y , ]
    )
    c<- gam (
      death ~ so2 + ns(trend,k=35) , poisson , na.action = na.omit , data = x[ x$year %in% y , ]
    )
    list( a , b ,c)
  }

models<- apply(year, 1 , fun , x = chicago )

#solution
apply(1:length(models),function(i) lapply(models[[i]],function(x) summary(x)$p.table[2,]))[[1]] #1st list component
#[[1]]
#    Estimate   Std. Error      z value     Pr(>|z|)
#6.054413e-04 1.474943e-04 4.104845e+00 4.045864e-05
#
#[[2]]
#    Estimate   Std. Error      z value     Pr(>|z|)
#0.0009999765 0.0003777224 2.6473846529 0.0081117027

#[[3]]
#    Estimate   Std. Error      z value     Pr(>|z|)
#5.643234e-03 9.023766e-04 6.253746e+00 4.007234e-10

res<-lapply(1:length(models),function(i) do.call(rbind,lapply(models[[i]],function(x) summary(x)$p.table[row.names(summary(x)$p.table)%in%c("pm10","ozone","so2"),c(1:2,4)])))
 names(res)<-1:length(res)
res1<- lapply(res,function(i) {row.names(i)<-c("pm10","ozone","so2");data.frame(i)})

library(abind)
res2<-abind(res1,along=1,hier.names=T)  #gives a matrix
colnames(res2)[2:3]<- c("Std.Error","Pr(>|z|)")

res3<- do.call(rbind,lapply(res,function(i) {row.names(i)<-c("pm10","ozone","so2");data.frame(i)}))
colnames(res3)[2:3]<- c("Std.Error","Pr(>|z|)")

 str(res2)
 #num [1:12, 1:3] 0.000605 0.001 0.005643 0.00059 0.000839 ...
 #- attr(*, "dimnames")=List of 2
 # ..$ : chr [1:12] "1.pm10" "1.ozone" "1.so2" "2.pm10" ...
 # ..$ : chr [1:3] "Estimate" "Std.Error" "Pr(>|z|)"

str(res3)
#'data.frame':    12 obs. of  3 variables:
# $ Estimate : num  0.000605 0.001 0.005643 0.00059 0.000839 ...
# $ Std.Error: num  0.000147 0.000378 0.000902 0.000172 0.000427 ...
 #$ Pr(>|z|) : num  4.05e-05 8.11e-03 4.01e-10 6.23e-04 4.96e-02 ...

res2
#            Estimate    Std.Error     Pr(>|z|)
#1.pm10  0.0006054413 0.0001474943 4.045864e-05
#1.ozone 0.0009999765 0.0003777224 8.111703e-03
#1.so2   0.0056432338 0.0009023766 4.007234e-10
#2.pm10  0.0005899052 0.0001724085 6.226404e-04
#2.ozone 0.0008389801 0.0004272480 4.956676e-02
#2.so2   0.0032899751 0.0009475318 5.163027e-04
#3.pm10  0.0005398889 0.0001551911 5.035438e-04
#3.ozone 0.0023890220 0.0004082119 4.845107e-09
#3.so2   0.0049121476 0.0008818088 2.539574e-08
#4.pm10  0.0009341888 0.0001760271 1.113999e-07
#4.ozone 0.0005461742 0.0004253987 1.991731e-01
#4.so2   0.0055712219 0.0011123419 5.484117e-07

Hope it helps.
A.K.






________________________________
From: Gustav Sigtuna <[hidden email]>
To: arun <[hidden email]>
Sent: Sunday, February 17, 2013 5:49 AM
Subject: Re: Select components of a list


Dear Arun,

Thanks again. The script works perfectly for GLM. Strangely, it does not work for GAM, although it has the same output for the linear part. I cannot figure out the error message. I have attached the gam code and  error message .


Thanks




On Sun, Feb 17, 2013 at 3:11 AM, arun <[hidden email]> wrote:

HI Gustav,

>
>If you need the combined output:
>res<-lapply(1:length(models),function(i) do.call(rbind,lapply(models[[i]],function(x) summary(x)$coef[row.names(summary(x)$coef)%in%c("pm10","ozone","so2"),c(1:2,4)])))
> names(res)<-1:length(res)
>res1<-do.call(rbind,lapply(res,function(i) {row.names(i)<-c("pm10","ozone","so2");data.frame(i)}))
>names(res1)[2:3]<- c("Std.Error","Pr(>|z|)")
>res1
>#            Estimate    Std.Error     Pr(>|z|)
>#1.pm10  0.0005999185 0.0001486195 5.423004e-05
>#1.ozone 0.0010117294 0.0003792739 7.640816e-03
>#1.so2   0.0026595441 0.0009352046 4.457766e-03
>#2.pm10  0.0005720549 0.0001740368 1.012696e-03
>#2.ozone 0.0009128304 0.0004364390 3.647954e-02
>#2.so2   0.0028256121 0.0010150314 5.373144e-03
>#3.pm10  0.0005099552 0.0001559620 1.076462e-03
>#3.ozone 0.0023896044 0.0004109854 6.087769e-09
>#3.so2   0.0024097381 0.0009563814 1.174744e-02
>#4.pm10  0.0009285593 0.0001766520 1.468764e-07
>#4.ozone 0.0005455392 0.0004301502 2.047076e-01
>#4.so2   0.0017251400 0.0011635156 1.381552e-01
>A.K.
>
>
>
>
>
>
>
>________________________________
>From: Gustav Sigtuna <[hidden email]>
>
>To: arun <[hidden email]>
>Sent: Saturday, February 16, 2013 7:44 PM
>
>Subject: Re: Select components of a list
>
>
>Hi Arun,
>
>Thanks for taking your time to find a solution.
>
>I have attached a R script that will recreate a comparable list from publicly available data. My list is longer and created by various models  than the one created here. However, the final output is similar to the one produced by script. My interest is to extract only the coefficients for  pm10., ozone and so2 (  Estimate,  Std. Error  and p value)    . 
>
>Thanks
>
>
>
>
>
>
>On Fri, Feb 15, 2013 at 9:04 PM, arun <[hidden email]> wrote:
>
>Dear Gustav,
>>Thank you for the data.  Could you select a smaller subset of the list and dput() that subset?  Your data is useful, but I would have to recreate list of lists from that to test and sometimes that may not accurate represent the format in your list as it is the summary().
>>Arun
>>
>>
>>
>>
>>
>>
>>
>>________________________________
>>From: Gustav Sigtuna <[hidden email]>
>>To: [hidden email]
>>Sent: Friday, February 15, 2013 4:56 AM
>>Subject: Re: Select components of a list
>>
>>
>>
>>Hi Arun,
>>
>>Thanks for your help. Your mail landed in my spam folder and just saw it by chance.
>>
>>I have attached a text file that contains the list of my model. It was extremely long, thus I took out the last part which is think is more important.
>>
>>
>>In brief I have an output from GAM model which resulted from analysis of  ozone at three time points on 12 data sets
>>
>>Thanks for your assistance
>>
>>
>>
>>
>>
>>On Wed, Feb 13, 2013 at 8:21 PM, <[hidden email]> wrote:
>>
>>Dear Lungo,
>>>
>>>If you can email ([hidden email]) me the `list` (dput(list)), I can take a look at it.  Probably, you understand that my previous solution was just guesswork. With regards to GLM, GAM, it is good to check the structure of the list (str()). It gives information about whether a `generic` tool could be applied to extract them or not.
>>>Cheers.
>>>Arun
>>>
>>><quote author='Lungo'>
>>>Dear Arun,  Your code and the example works fine. However my list is quite
>>>different from the one showed in your example.   As I have shown in my
>>>question above I have 12 lists each having 3 lists underneath.  I get the
>>>lists by different models (GLM, GAM ) but the output  I aim to have is the
>>>estimates of the explanatory variable which is placed next to the intercept.
>>>Thus I am looking for a “generic” tool that would extract these lists.
>>></quote>
>>>Quoted from:
>>>http://r.789695.n4.nabble.com/Select-components-of-a-list-tp4658295p4658389.html
>>> 
>>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Select components of a list

arun kirshna
In reply to this post by arun kirshna
Sorry, I just noticed that in the first line of the solution 'l' got stripped off, it should be read as 'lapply` instead of 'apply`.

lapply(1:length(models),function(i) lapply(models[[i]],function(x) summary(x)$p.table[2,]))[[1]] #1st list component
Thanks,

A.K.





________________________________
From: Gustav Sigtuna <[hidden email]>
To: arun <[hidden email]>
Sent: Sunday, February 17, 2013 5:49 AM
Subject: Re: Select components of a list


Dear Arun,

Thanks again. The script works perfectly for GLM. Strangely, it does not work for GAM, although it has the same output for the linear part. I cannot figure out the error message. I have attached the gam code and  error message .

Thanks




On Sun, Feb 17, 2013 at 3:11 AM, arun <[hidden email]> wrote:

HI Gustav,

>
>If you need the combined output:
>res<-lapply(1:length(models),function(i) do.call(rbind,lapply(models[[i]],function(x) summary(x)$coef[row.names(summary(x)$coef)%in%c("pm10","ozone","so2"),c(1:2,4)])))
> names(res)<-1:length(res)
>res1<-do.call(rbind,lapply(res,function(i) {row.names(i)<-c("pm10","ozone","so2");data.frame(i)}))
>names(res1)[2:3]<- c("Std.Error","Pr(>|z|)")
>res1
>#            Estimate    Std.Error     Pr(>|z|)
>#1.pm10  0.0005999185 0.0001486195 5.423004e-05
>#1.ozone 0.0010117294 0.0003792739 7.640816e-03
>#1.so2   0.0026595441 0.0009352046 4.457766e-03
>#2.pm10  0.0005720549 0.0001740368 1.012696e-03
>#2.ozone 0.0009128304 0.0004364390 3.647954e-02
>#2.so2   0.0028256121 0.0010150314 5.373144e-03
>#3.pm10  0.0005099552 0.0001559620 1.076462e-03
>#3.ozone 0.0023896044 0.0004109854 6.087769e-09
>#3.so2   0.0024097381 0.0009563814 1.174744e-02
>#4.pm10  0.0009285593 0.0001766520 1.468764e-07
>#4.ozone 0.0005455392 0.0004301502 2.047076e-01
>#4.so2   0.0017251400 0.0011635156 1.381552e-01
>A.K.
>
>
>
>
>
>
>
>________________________________
>From: Gustav Sigtuna <[hidden email]>
>
>To: arun <[hidden email]>
>Sent: Saturday, February 16, 2013 7:44 PM
>
>Subject: Re: Select components of a list
>
>
>Hi Arun,
>
>Thanks for taking your time to find a solution.
>
>I have attached a R script that will recreate a comparable list from publicly available data. My list is longer and created by various models  than the one created here. However, the final output is similar to the one produced by script. My interest is to extract only the coefficients for  pm10., ozone and so2 (  Estimate,  Std. Error  and p value)    . 
>
>Thanks
>
>
>
>
>
>
>On Fri, Feb 15, 2013 at 9:04 PM, arun <[hidden email]> wrote:
>
>Dear Gustav,
>>Thank you for the data.  Could you select a smaller subset of the list and dput() that subset?  Your data is useful, but I would have to recreate list of lists from that to test and sometimes that may not accurate represent the format in your list as it is the summary().
>>Arun
>>
>>
>>
>>
>>
>>
>>
>>________________________________
>>From: Gustav Sigtuna <[hidden email]>
>>To: [hidden email]
>>Sent: Friday, February 15, 2013 4:56 AM
>>Subject: Re: Select components of a list
>>
>>
>>
>>Hi Arun,
>>
>>Thanks for your help. Your mail landed in my spam folder and just saw it by chance.
>>
>>I have attached a text file that contains the list of my model. It was extremely long, thus I took out the last part which is think is more important.
>>
>>
>>In brief I have an output from GAM model which resulted from analysis of  ozone at three time points on 12 data sets
>>
>>Thanks for your assistance
>>
>>
>>
>>
>>
>>On Wed, Feb 13, 2013 at 8:21 PM, <[hidden email]> wrote:
>>
>>Dear Lungo,
>>>
>>>If you can email ([hidden email]) me the `list` (dput(list)), I can take a look at it.  Probably, you understand that my previous solution was just guesswork. With regards to GLM, GAM, it is good to check the structure of the list (str()). It gives information about whether a `generic` tool could be applied to extract them or not.
>>>Cheers.
>>>Arun
>>>
>>><quote author='Lungo'>
>>>Dear Arun,  Your code and the example works fine. However my list is quite
>>>different from the one showed in your example.   As I have shown in my
>>>question above I have 12 lists each having 3 lists underneath.  I get the
>>>lists by different models (GLM, GAM ) but the output  I aim to have is the
>>>estimates of the explanatory variable which is placed next to the intercept.
>>>Thus I am looking for a “generic” tool that would extract these lists.
>>></quote>
>>>Quoted from:
>>>http://r.789695.n4.nabble.com/Select-components-of-a-list-tp4658295p4658389.html
>>> 
>>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.