[R] Object item extraction

Eric Lecoutre lecoutre at stat.ucl.ac.be
Mon Apr 4 11:03:10 CEST 2005



Any R output is an object you can manipulate basically using
exctractions functions $, [ and [[
To look at the content of the object, try:

> str(model)

And (in this case)

> str(summary(model))

Then you can extract what you need, such as:

> summary(model)$adj.r.squared
[1] 0.02158191    (an other model...)

 1.419101  1.000000 18.000000 
> summary(model)$fstatistic
    value     numdf     dendf 
 1.419101  1.000000 18.000000 
> summary(model)$fstatistic[["value"]]
[1] 1.419101

HTH,

Eric



Eric Lecoutre
UCL /  Institut de Statistique
Voie du Roman Pays, 20
1348 Louvain-la-Neuve
Belgium

tel: (+32)(0)10473050
lecoutre at stat.ucl.ac.be
http://www.stat.ucl.ac.be/ISpersonnel/lecoutre

If the statistics are boring, then you've got the wrong numbers. -Edward
Tufte   


> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Smit, 
> R. (Robin) (IenT)
> Sent: lundi 4 avril 2005 10:36
> To: r-help at stat.math.ethz.ch
> Subject: [R] Object item extraction
> 
> 
> Hello 
>  
> I am able to extract partial regression coefficients from a 
> fitted model object "model", i.e.
>  
> model <- lm(var.sel.gkm, weights = count.gkm, data = DATA)
> 
> summary(model)
> 
> write.table(model$coef, file = "C:/coef_CO_gkm.txt", 
> row.names = TRUE, col.names = TRUE)
> 
> I was wondering if anyone could advise me how to extract 
> other object items such as std. error, t-values and adjusted 
> R2 in the same way.
>  
> Many thanks.
> Robin Smit
> 
>  
> 
> This e-mail and its contents are subject to the DISCLAIMER at 
> http://www.tno.nl/disclaimer/email.html
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list