r - 圆形功能不再适用于鼠标输出
问题描述
由于将 R 更新到 4.0.0 并重新安装mice
,该round()
功能似乎不再适用于鼠标输出,但会产生错误消息。
例如(使用 iris 数据集):
library(missForest) # for the prodNA function
library(mice) # for the imputations
#Creating dataset with missing values (NAs)
iris.mis <- prodNA(iris, noNA = 0.1)
head(iris.mis)
#Imputation
imputed_data <- mice(data = iris.mis, m = 5, method = "pmm",
maxit = 50, seed = 500)
model <- with(data = imputed_data, lm(Sepal.Length ~ Sepal.Width))
round(summary(pool(model), conf.int = TRUE, exponentiate = TRUE), 2)
这会产生错误消息:
Math.data.frame 中的错误(列表(术语 = 1:2,估计 = c(760.13466726231,:数据框中的非数字变量:术语)
使用summary(pool(model), conf.int = T, exponentiate = T)
效果很好。
在更新 R 和鼠标之前,我从来没有遇到过 R 中的 round 函数的问题。
解决方案
我不知道为什么会发生这种变化,但是老鼠的新闻文件 在 3.8 版中说
现在有一个更灵活的
pool()
功能,可以更好地与broom
和broom.mixed
包集成。
将行名改为列是有道理的,因为这与 tidyverse 机制(如and )term
更兼容。broom
broom.mixed
您可以要求 R 舍入除第一列之外的所有列:
ss <- summary(pool(model), conf.int = TRUE, exponentiate = TRUE)
ss[-1] <- round(ss[-1],2)
ss
## term estimate std.error statistic df p.value 2.5 % 97.5 %
## 1 (Intercept) 670.98 0.48 13.69 143.68 0.00 262.19 1717.15
## 2 Sepal.Width 0.80 0.15 -1.44 143.36 0.15 0.59 1.09
如果你喜欢 tidyverse,你可以
mutate_if(ss,is.numeric, round, 2)
推荐阅读
- javascript - 了解 Django/REST/JS 代码功能
- c++ - C++ winsock 服务器接受函数返回 10022 错误
- c++ - 从终端手动运行时,我的项目找不到它的库
- javascript - 通过 JavaScript 动态添加 MDL 文本输入,而不是通过 AJAX
- gnuplot - gnuplot 没有在 y 轴上显示一个圆圈的正确比例
- android - 为什么我的 xml、gradle 和 value 文件会自行改变?
- php - 在for循环中显示一个月中每一天的记录数以显示该月的日期
- c# - Microsoft Graph API 超时异常
- kendo-ui - 防止 kendo ui 图表工具提示在图表刷新后消失
- c - 在 Powershell/CMD 中运行 make 会给出 Error2