我正在尝试通过使用 nlme 包中的 lmList() 为不同级别的因子生成箱线图。虽然它适用于帮助页面中的示例,但我的数据返回以下错误:
library(nlme)
##dataframe used (simplified):
**data.1**
IDf x.var.1 y.var.1
1 1 1 1.856491
2 1 2 2.999224
3 1 3 3.943896
4 1 4 4.903249
5 1 5 6.034319
6 2 6 6.986847
7 2 7 8.024806
8 2 8 9.139255
9 2 9 9.986437
10 2 10 10.760508
##creating the lmlist file fm1
fm2 <- lmList(y.var.1 ~ x.var.1 | IDf, data.1, na.action = na.exclude)
##plotting fm2
Call:
Model: y.var.1 ~ x.var.1 | IDf
Data: data.1
Coefficients:
(Intercept) x.var.1
1 0.8695317 1.0259681
2 1.3724091 0.9508952
Degrees of freedom: 10 total; 6 residual
Residual standard error: 0.1042786
##plotting boxplots ##(or any kinds of plots really)
> plot(fm2, IDf ~ resid(.))
##returning error:
Error in plot.lmList(fm2, IDf ~ resid(.)) : object 'cF' not found
现在我已经搜索和搜索,但我似乎无法弄清楚这个对象'cF'应该是什么意思,任何帮助将不胜感激!
##EDIT:
> dput(data.1)
structure(list(IDf = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2), x.var.1 = 1:10,
y.var.1 = c(1.85649137285461, 2.99922390104585, 3.94389558063648,
4.90324945760581, 6.03431888678115, 6.98684730318977, 8.0248061251629,
9.13925481513909, 9.98643662828079, 10.7605079666861)), .Names = c("IDf",
"x.var.1", "y.var.1"), row.names = c(NA, -10L), class = "data.frame")