Reputation: 4716
Question upfront: If use summary
, I get a much more detailed view on my model than just print
produces. In R, how can I know what extra information my object holds, such as revealed by summary
, which I would not see without the knowledge of that generic function? Put in other words, how do I know what functions are available that yield additional information?
I conduct a quick linear least squares regression with:
model <- lm(seq(10) + runif(10) ~ seq(10))
Now, when I print the model, I get:
print(model)
Call:
lm(formula = seq(10) + runif(10) ~ seq(10))
Coefficients:
(Intercept) seq(10)
0.3642 1.0413
Instead, when I use summary(model)
, I get a much more detailed view. Why wouldn't I obtain that in the first place?
> summary(model)
Call:
lm(formula = seq(10) + runif(10) ~ seq(10))
Residuals:
Min 1Q Median 3Q Max
-0.42297 -0.20032 0.00175 0.18183 0.39827
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.36419 0.18980 1.919 0.0913 .
seq(10) 1.04133 0.03059 34.043 6.06e-10 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.2778 on 8 degrees of freedom
Multiple R-squared: 0.9931, Adjusted R-squared: 0.9923
F-statistic: 1159 on 1 and 8 DF, p-value: 6.057e-10
Upvotes: 2
Views: 4788
Reputation: 263332
If you want a list of methods to use on a particular object try:
methods(class(object))
There was a relatively recent change to that function which now offers the S4 methods as well as the S3 ones it previously listed. It used to be that one needed to execute both that code as well as:
showMethods( classes=class(object) )
I will often use:
names(object)
... because the output of str(object) will be so extensive, but I really only want to check a few places and need the correct element name.
Upvotes: 4