回归后控制拟合总结的数字显示

时间:2014-03-26 19:02:17

标签: r

如何控制summary(fit)的数字显示,现在它在小数点后显示太多数字。试图使用options(digits=3),但它不起作用

> fit <- lm(y ~ x1 + x2 + x3)
> summary(fit) # show results

1 个答案:

答案 0 :(得分:5)

fit <- lm(mpg~wt,mtcars)
print(summary(fit),digits=2)

# Call:
# lm(formula = mpg ~ wt, data = mtcars)

# Residuals:
#    Min     1Q Median     3Q    Max 
#  -4.54  -2.36  -0.13   1.41   6.87 

# Coefficients:
#             Estimate Std. Error t value Pr(>|t|)    
# (Intercept)    37.29       1.88    19.9   <2e-16 ***
# wt             -5.34       0.56    -9.6    1e-10 ***
# ---
# Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

# Residual standard error: 3 on 30 degrees of freedom
# Multiple R-squared:  0.75,    Adjusted R-squared:  0.74 
# F-statistic:  91 on 1 and 30 DF,  p-value: 1.3e-10