animate ggplot bar chart for the sums

I am trying to make an animation for the total number of "shutdowns" in countries in one year. ( sorry, the month is an integer here but I have it as date in my dataset) my animation doesn't show aggregation or the total of each month plus the previous month how can I fix it. Thanks

Country <- c("India", "India", "Iran","Pakistan" ,"Iran", "Pakistan")
month <- c(2,4,8,12, 3, 5)
event <- c("Shutdown","Shutdown","Shutdown")
df <- data.frame(Country,month, event)

df %>% select(Country,month) %>%
ggplot(aes(x= fct_rev(fct_infreq(Country)))) +
geom_bar(stat="count")+
transition_time(month)+
labs(title = paste("Countries with the most shutdowns by {frame_time}")) +
coord_flip()+
theme(panel.background = element_blank())

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.