I think I've discovered another issue with transitioning on generated stats. When trying to use group to manipulate object permanence, the transitions get disrupted.
library(ggplot2)
library(gganimate)
library(ungeviz) # devtools::install_github("clauswilke/ungeviz")
# this works
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
stat_smooth_draws(times = 20) +
theme_bw() +
transition_states(stat(.draw), 1, 2)

So far so good. Now, when I try to make lines fade in and out rather than transform, I end up with no animation.
# this doesn't
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
stat_smooth_draws(times = 20, aes(group = stat(.draw))) +
theme_bw() +
transition_states(stat(.draw), 1, 2) +
enter_fade() + exit_fade()
#> nframes and fps adjusted to match transition

However, things work fine if I do the same with an external data frame rather than a stat.
library(mgcv)
#> Loading required package: nlme
#> This is mgcv 1.8-24. For overview type 'help("mgcv-package")'.
fit <- gam(mpg ~ s(hp), data = mtcars, method = "REML")
newdata <- data.frame(hp = seq(min(mtcars$hp), max(mtcars$hp), length.out = 100))
sample_df <- sample_outcomes(fit, newdata, 10, unconditional = TRUE)
ggplot(mtcars, aes(hp, mpg)) +
geom_point(color = "grey30", size = 0.5) +
geom_line(data = sample_df, aes(group = .draw), color = "blue") +
theme_bw() +
transition_states(.draw, 1, 2) +
enter_fade() + exit_fade()

I think I've discovered another issue with transitioning on generated stats. When trying to use
groupto manipulate object permanence, the transitions get disrupted.So far so good. Now, when I try to make lines fade in and out rather than transform, I end up with no animation.
However, things work fine if I do the same with an external data frame rather than a stat.