Show the code
library(dplyr)
library(plotly)
library(knitr)
DF <- data.frame(
year = rep(seq(1980L, 2020L), each = 12),
month = rep(1:12, 41),
month_char = rep(factor(month.abb), 41),
avg_depth = runif(492)
)
DF %>%
plot_ly(
x = ~year,
y = ~avg_depth,
frame = ~paste0(sprintf("%02d", month), " - ", month_char),
type = 'bar'
) %>%
animation_opts(frame = 1500, redraw = FALSE) %>% # Increase the frame duration for slower animation
animation_slider(
currentvalue = list(prefix = "Month: ")
)