I'm trying to animate points and a loess regression line, so they appear/are revealed simultaneously along year, but I'm returned with an error, as described below with a reprex.
This would be the ideal animation: https://user-images.githubusercontent.com/1775316/49728400-f0ba1b80-fc72-11e8-86c5-71ed84b247db.gif Unfortunately, the thread where I found this did not have the accompanying code.
See my reprex problem here:
#Animate points and regression loess line along with dates at the same time
library(MASS) #for phones reprex dataset
phones <- data.frame(phones) #Prepare reprex data
library(ggplot2) #for plotting
library(gganimate) #for animation
#Animation
ggplot(phones, aes(x = year, y = calls)) +
geom_point() + geom_smooth(method = "loess", colour = "orange",
se = FALSE) +
transition_time(year) + shadow_mark() + ease_aes("linear")
This returns the error:
Error in `$<-.data.frame`(`*tmp*`, "group", value = "") :
replacement has 1 row, data has 0
Some have suggested I insert aes(group = year)
in geom_smooth()
, but that returns the same error.
Thanks for all your help in advance!