Skip to content
Prev 275379 / 398506 Next

extract the p value

On 24/10/2011 1:47 PM, Jim Bouldin wrote:
It's not part of the object, it is computed when the object is printed.  
To see the print method, do this:

class(test2[[1]])

(which will print "summary.lm" if I'm reading your code properly).  Then 
print.summary.lm is the print method:

getAnywhere(print.summary.lm)

It's fairly long, but I think the part you want is

         cat(",\tAdjusted R-squared:", formatC(x$adj.r.squared,
             digits = digits), "\nF-statistic:", formatC(x$fstatistic[1L],
             digits = digits), "on", x$fstatistic[2L], "and",
             x$fstatistic[3L], "DF,  p-value:", 
format.pval(pf(x$fstatistic[1L],
                 x$fstatistic[2L], x$fstatistic[3L], lower.tail = FALSE),
                 digits = digits), "\n")

Here, x is the summary object.

Duncan Murdoch