diff --git a/Evaluation.Rmd b/Evaluation.Rmd index 66e584fb3..3f64a3bbf 100644 --- a/Evaluation.Rmd +++ b/Evaluation.Rmd @@ -993,7 +993,7 @@ There are two basic ways to overcome this challenge: \@ref(non-standard-ast)). For modelling functions this means that the captured call is suboptimal: - ```{r} + ```{r, eval = FALSE} resample_lm1 <- function(formula, data, env = caller_env()) { formula <- enexpr(formula) resample_data <- resample(data, n = nrow(data)) @@ -1003,6 +1003,10 @@ There are two basic ways to overcome this challenge: eval(lm_call, env) } resample_lm1(y ~ x, data = df)$call + #> lm(y ~ x, data = ) + #> lm(formula = y ~ x, data = list(x = c(3L, 7L, 4L, 4L, + #> 2L, 7L, 2L, 1L, 8L, 9L), y = c(13.21, 27.04, 18.63, + #> 18.63, 10.99, 27.04, 10.99, 7.83, 28.14, 32.72))) ``` 1. Alternatively you can create a new environment that inherits from the @@ -1028,7 +1032,7 @@ There are two basic ways to overcome this challenge: 1. Why does this function fail? - ```{r, error = TRUE} + ```{r, eval = FALSE} lm3a <- function(formula, data) { formula <- enexpr(formula) @@ -1036,6 +1040,8 @@ There are two basic ways to overcome this challenge: eval(lm_call, caller_env()) } lm3a(mpg ~ disp, mtcars)$call + #> Error in as.data.frame.default(data, optional = TRUE): + #> cannot coerce class ‘"function"’ to a data.frame ``` 1. When model building, typically the response and data are relatively