r - boxCox() 不接受 map() 创建的线性模型,尽管是同一类?
问题描述
我有几个模型,我试图一次生成,然后运行单独的boxCox()
转换。但是每次我尝试运行boxCox()
时,我都会遇到一个奇怪的错误。
我认为这与.x
使用map()
. 这是一个小代表来证明我的错误:
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(purrr)
library(broom)
library(car)
#> Loading required package: carData
#>
#> Attaching package: 'car'
#> The following object is masked from 'package:purrr':
#>
#> some
#> The following object is masked from 'package:dplyr':
#>
#> recode
formulas <- c(mpg ~ wt,
sqrt(mpg) ~ wt,
sqrt(mpg) ~ sqrt(wt))
proj_lm <- tibble(formulas) %>%
mutate(lm_models = map(formulas, ~lm(formula = .x, data = mtcars)))
boxCox(proj_lm$lm_models[[1]])
#> Error in stats::model.frame(formula = .x, data = mtcars, drop.unused.levels = TRUE): object '.x' not found
由reprex 包(v0.2.1)于 2019 年 1 月 11 日创建
解决方案
推荐阅读
- sql - 计算列相对于总计数的比例
- sql - 对数值列的前 1 个和后 1 个数值进行红移求和窗函数,即使这些值不存在
- c - 通过未命名管道进行进程通信
- device - vulkan物理设备和实例之间有什么关系?
- java - Spring Hibernate NullPointerException 依赖注入
- javascript - Discord.js 检查机器人,循环提及
- testing - TestCafe --retry-test-pages 空页面的行为
- mongodb - Mongod服务器无法启动
- scala - 如何计算 2 个时间戳变量之间的持续时间?
- reactjs - ReactJS - 如何修复聊天应用程序中的编译错误?