PREMISE: I am trying to debug this:
https://github.com/masurp/specr/issues/29
I located the error in a function
map2(x,y,~do.call(.x,list(df,.y))
REPRODUCIBLE ISSUE:
df = tibble(y = rnorm(100),
x = rnorm(100)
)
model = list()
lm -> LM
lm -> model$LM
LM and model$LM should be equivalent, however,
this code works:
specr:::setup_specs(y = "y",
x = "x",
model = "LM"
) %>%
dplyr::mutate(formula = pmap(.,
specr:::create_formula)
) %>% tidyr::unnest(formula) %>%
dplyr::mutate(res = map2(.data$model,
formula,
~do.call(.x,
list(data = df,
formula = .y))))
The same exact code don't if the param model="model$LM"
specr:::setup_specs(y = "y",
x = "x",
model = "model$LM"
) %>%
dplyr::mutate(formula = pmap(.,
specr:::create_formula)
) %>% tidyr::unnest(formula) %>%
dplyr::mutate(res = map2(.data$model,
formula,
~do.call(.x,
list(data = df,
formula = .y))))
The error:
Error in `dplyr::mutate()`:
! Problem while computing `res = map2(.data$model,
formula, ~do.call(.x, list(data = df, formula = .y)))`.
Caused by error in `model$LM`:
! could not find function "model$LM"