我正在尝试lme4::lmer
在计划中拟合一些模型drake
,但出现错误
未找到“数据”,公式环境中缺少一些变量
如果我替换一个lm
模型,它会起作用。
这是一个可重现的示例
library(drake)
library(lme4)
#> Loading required package: Matrix
#>
#> Attaching package: 'Matrix'
#> The following object is masked from 'package:drake':
#>
#> expand
plan_lm <- drake_plan(
dat = iris,
mod = lm(Sepal.Length ~ Petal.Length, data = dat)
)
make(plan_lm)
#> ℹ Consider drake::r_make() to improve robustness.
#> ▶ target dat
#> ▶ target mod
plan_lmer <- drake_plan(
dat1 = iris,
mod1 = lmer(Sepal.Length ~ Petal.Length, data = dat1)
)
make(plan_lmer)
#> ▶ target dat1
#> ▶ target mod1
#> x fail mod1
#> Error: target mod1 failed.
#> diagnose(mod1)$error$message:
#> 'data' not found, and some variables missing from formula environment
#> diagnose(mod1)$error$calls:
#> lme4::lFormula(formula = Sepal.Length ~ Petal.Length, data = dat1,
#> control = list("nloptwrap", TRUE, 1e-05, TRUE, FALSE, list(
#> "ignore", "stop", "ignore", "stop", "stop", "message+drop.cols",
#> "warning", "stop"), list(list("warning", 0.002, NULL),
#> list("message", 1e-04), list("warning", 1e-06)), list()))
#> lme4:::checkFormulaData(formula, data, checkLHS = control$check.formula.LHS ==
#> "stop")
#> base::stop("'data' not found, and some variables missing from formula environment",
#> call. = FALSE)
Created on 2020-07-29 by the reprex package (v0.3.0)
有什么建议么?