Running examples in 'coursekata-Ex.R' failed
The error most likely occurred in:

> ### Name: middle
> ### Title: Find a percentage of a distribution
> ### Aliases: middle tails outer lower upper
> 
> ### ** Examples
> 
> 
> upper(1:10, .1)
 [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE
> lower(1:10, .2)
 [1]  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> middle(1:10, .5)
 [1] FALSE FALSE  TRUE  TRUE  TRUE  TRUE  TRUE  TRUE FALSE FALSE
> tails(1:10, .5)
 [1]  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE  TRUE  TRUE
> 
> sampling_distribution <- do(1000) * mean(rnorm(100, 5, 10))
> sampling_distribution %>%
+   gf_histogram(~mean, data = sampling_distribution, fill = ~ middle(mean, .68)) %>%
+   gf_refine(scale_fill_manual(values = c("blue", "coral")))
Error:
! Problem while computing aesthetics.
ℹ Error occurred in the 1st layer.
Caused by error in `as.data.frame.default()`:
! cannot coerce class '"function"' to a data.frame
Backtrace:
     ▆
  1. ├─base (local) `<fn>`(x)
  2. ├─ggformula:::print.gf_ggplot(x)
  3. ├─base::NextMethod()
  4. ├─ggplot2 (local) `print.ggplot2::ggplot`(x)
  5. │ ├─ggplot2::ggplot_build(x)
  6. │ └─ggplot2 (local) `ggplot_build.ggplot2::ggplot`(x)
  7. │   └─ggplot2:::by_layer(...)
  8. │     ├─rlang::try_fetch(...)
  9. │     │ ├─base::tryCatch(...)
 10. │     │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
 11. │     │ │   └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
 12. │     │ │     └─base (local) doTryCatch(return(expr), name, parentenv, handler)
 13. │     │ └─base::withCallingHandlers(...)
 14. │     └─ggplot2 (local) f(l = layers[[i]], d = data[[i]])
 15. │       └─l$compute_aesthetics(d, plot)
 16. │         └─ggplot2 (local) compute_aesthetics(..., self = self)
 17. │           └─ggplot2:::eval_aesthetics(aesthetics, data)
 18. │             └─base::lapply(aesthetics, eval_tidy, data = data, env = env)
 19. │               └─rlang (local) FUN(X[[i]], ...)
 20. ├─coursekata::middle(mean, 0.68)
 21. │ └─coursekata::upper(x, tail_prop, !greedy)
 22. │   └─base::data.frame(x = x, original_pos = seq_along(x))
 23. │     ├─base::as.data.frame(x[[i]], optional = TRUE)
 24. │     └─base::as.data.frame.default(x[[i]], optional = TRUE)
 25. │       └─base::stop(...)
 26. └─base::.handleSimpleError(...)
 27.   └─rlang (local) h(simpleError(msg, call))
 28.     └─handlers[[1L]](cnd)
 29.       └─cli::cli_abort(...)
 30.         └─rlang::abort(...)
Execution halted