[R] Help with reading information of "summary"-Object

Erik Iverson eriki at ccbr.umn.edu
Thu May 13 19:10:08 CEST 2010


Tino Schöllhorn wrote:
> Hi,
> I am quite new to R - but quite expierience in programming. 

Welcome to R!  It's easiest if you give reproducible examples so we can 
help you.  You can include code to create objects, or use the ?dput 

> Nonetheles 
> I have some problemes in accessing information of the "summary" object. 
> Here is what I do:
> model <- lm ( y ~ myVariable )
> "summary(model)" gives me an object which has a lot of information about 
> the regression. Now I'd like to access programmatically the level of 
> significance which is marked with "***" and ("**") according to its 
> confidence-interval. As I can access all information of the coefficients 
> via
> summary(model)$coeff["myVariable"]

Use the ?coef function for this.

> I am now struggling to access the information of the level of significance.
> Does anyone has an idea how I could achieve that? Or where I could find 
> a similar example?

In this case, you need to know one of the most important R functions, 
str, which tells you the structure of any object.  This will let you 
know what is available in your objects.  Assign your summary object to a 
variable, say summary.model, and then do:

 > str(coef(summary(model)))

You can then get at the p.values through the usual indexing techniques, 
by name or by row, column numbering.

 From the statistical point of view, we're not sure what you're working 
on, but there are many considerations to take into account if you're 
using p-values from regression fits as some sort of screening tool.

More information about the R-help mailing list