Goal:
Import, transform / prep, and animate a coronavirus dataset from .xlsx using only R.
Text from Reproducible Error:
The problem is with your transformation of the column names into Dates. That seems to introduce NAs into the Dates, and makes the range indeterminate, which gganimate uses for the start and end of the animation.
What worked for me was:
names(wide) = janitor::make_clean_names(names(wide))
and
long <- wide %>%
gather(Date, Cases, -county_name, -population) %>%
rename(County = county_name, Population = population) %>%
mutate(Date = as.Date(str_remove(Date, "cases_"), format = "%m_%d")) %>%
mutate(Rate = Cases/Population)
long %>% filter(is.na(Date))
Alternatively, you could use str_remove(Date, "\\D+")
instead of cleaning up the column names beforehand.