I'm trying to use rowwise
to produce one plot per dataframe row as follows:
library(dplyr)
library(ggplot2)
params = tribble(
~a, ~b,
4, 1,
9, 1,
6, 2,
)
plot_beta <- function(p, a, b){
pl <- qplot(p, dbeta(p, a, b), geom="line")
list(pl)
}
params %>%
rowwise() %>%
mutate(gp = plot_beta(p, a, b)) %>%
pull(gp)
for which R returns a cool but not awesomely helpful error message:
Error:
! Obsolete data mask.
✖ Too late to resolve `a` after the end of `dplyr::mutate()`.
ℹ Did you save an object that uses `a` lazily in a column in the `dplyr::mutate()` expression ?
Run `rlang::last_error()` to see where the error occurred.
I think I do "save an object that uses a
lazily in a column in the dplyr::mutate()
" but that doesn't help to get how to fix this.
Changing a
and b
to {{a}}
or .data[["a"]]
doesn't help.