0

I have a dataset that has a column of years from 1965 to 2020 and Teams that have won the championship in the respective years.

I am trying to create a racing bar chart and so far I have been struggling to create the required dataset to create the animated GIF

  df1 <- df %>% 
     group_by(Team) %>% 
     mutate(cups = 1:n()) %>% 
     ungroup() %>% 
     group_by(Year) %>% spread(Year, cups) %>% 
     replace(is.na(.),0)

which brings a result of the following format. enter image description here

Kindly assist in how I should go about completing this racing bar chart as I have browsed through several resources but I still cant seem to crack it..

Peter
  • 11
  • 4
  • 2
    please provide a reprex – Bruno Oct 20 '21 at 17:03
  • 2
    I'd pivot the data into long format using `tidyr` with`%>% pivot_longer(-Team) %>% ` and then here's an approach: https://stackoverflow.com/questions/53162821/animated-sorted-bar-chart-with-bars-overtaking-each-other/53163549#53163549 – Jon Spring Oct 20 '21 at 17:27

0 Answers0