I have a dataframe df:
df = data.frame(name = "bird",
value = seq(0, 1, length.out = 100),
step = 1:100)
I want to animate this data by showing the variable value increasing. In the animation, I want to show the current step and value for that step.
This is what I have done so far:
library(ggplot2)
gg = ggplot(df, aes(name, value)) +
geom_bar(stat = "identity", fill = "darkgreen") +
coord_cartesian(ylim = c(0, 1))
gg + gganimate::transition_states(step) +
ggtitle("Step: {closest_state}",
subtitle = "Value: {frame}")
step is shown correctly, but clearly value is not.


