在运行R
包coefplot
中的命令multiplot
时,有人面临与我相同的情况吗?
即使是这个例子:
data(diamonds)
model1 <- lm(price ~ carat + cut, data=diamonds)
model2 <- lm(price ~ carat + cut + color, data=diamonds)
model3 <- lm(price ~ carat + color, data=diamonds)
multiplot(model1, model2, model3)
我现在收到以下错误:
Error in get(x, envir = this, inherits = inh)(this, ...) :
attempt to apply non-function
有什么提示吗?
最佳答案
这个答案有点离题,但我发现 broom
和 dotwhisker
包的稍微更新的组合很有用 - broom
是后端(将模型转换为“整齐”的系数数据帧),而 dotwhisker
是前端(通过相当薄的 ggplot2
层创建绘图)
library(ggplot2)
library(dotwhisker)
library(broom)
更新:重新安装了dotwhisker
v 0.2.0.3,这似乎有效:
dwplot(list(model1,model2,model3))
如果您想动态选择不同的模型名称,也可以dwplot(list(m1=model1,m2=model2,m3=model3))
。
或者,为了更好地控制,您可以自己构建完整的数据框架:
mList <- list(carat_cut=model1, carat_cut_color=model2,
carat_color=model3)
library(plyr)
## extract tidy data frames and combine them ...
mFrame <- ldply(mList,tidy,conf.int=TRUE,.id="model")
现在你可以这样做
dwplot(mFrame)
关于r - R 中 coefplot 包中的命令 multiplot 面临错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34665591/