【发布时间】:2013-04-01 02:05:59
【问题描述】:
我正在寻找的只是B1(newx) 线性模型系数的值,而不是名称。我只想要 0.5 的值。我不想要“newx”这个名字。
newx <- c(0.5,1.5.2.5)
newy <- c(2,3,4)
out <- lm(newy ~ newx)
out 看起来像:
Call:
lm(formula = newy ~ newx)
Coefficients:
(Intercept) newx
1.5 1.0
我到了这里。但现在我被困住了。
out$coefficients["newx"]
newx
1.0
【问题讨论】:
-
as.numeric(out$coefficients["newx"]) -
as.numeric 确实有效。也许这是一种低成本的强制数字方式?
-
可以使用
newx(2)的索引号代替out[[1]][[2]]这样的名称。