我尝试一次生成多个模型,然后运行单独的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 package(v0.2.1)于2019-01-11创建