r - R 中 coefplot 包中的命令 multiplot 面临错误

标签 r coefplot

在运行Rcoefplot中的命令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

有什么提示吗?

最佳答案

这个答案有点离题,但我发现 broomdotwhisker 包的稍微更新的组合很有用 - 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/

相关文章:

r - 在 R 的 "contains"包中找不到 "purrr"函数

r - 在 R 中,如何将时间戳间隔数据拆分为常规插槽?

r - 在 R 中使用聚合为另一个变量的相同值查找一个变量的唯一值

r - 从 R 内部堆积床文件

stata - 在 coefplot 中仅绘制交互项

R:对分组变量的每个成对组合进行 t 检验,对 ID 变量中的每个元素进行

stata - 随时间绘制相同的系数

Stata 系数图 : plot coefficients and corresponding confidence intervals on 2nd axis

stata - 在 Stata coefplot 中编辑置信区间