0
# A tibble: 10,336 x 5
# Groups:   Player [2,291]
   Player       Year Country   Total Cumulative.Sum
   <chr>       <dbl> <chr>     <dbl>          <dbl>
 1 A Balbirnie  2010 Ireland      29             29
 2 A Balbirnie  2014 Ireland      60             89
 3 A Balbirnie  2015 Ireland     362            451
 4 A Balbirnie  2017 Ireland     306            757
 5 A Balbirnie  2018 Ireland     489           1246
 6 A Balbirnie  2019 Ireland     567           1813
 7 A Balbirnie  2020 Ireland      97           1910
 8 A Bhandari   2000 India         0              0
 9 A Bhandari   2004 India         0              0
10 A Dananjaya  2012 Sri Lanka     0              0
# ... with 10,326 more rows

Hello,

Is there an easy way I can create rows for the missing years by player? so if a player didn't play in 2014, his total would be 0 for that year and cumsum would be the same as previous year. I need to show all years for all players.

  • Hi Adetya. This question is way too vague to get a proper answer. Can you at least show us your data structure? Otherwise this question is likely to get closed quickly. – Allan Cameron Aug 31 '20 at 14:10
  • Check `tidyr::complete` , This post might help https://stackoverflow.com/questions/51019672/complete-dataframe-with-missing-combinations-of-values – Ronak Shah Aug 31 '20 at 14:10
  • Hi Allan, I thought I added the df image but it didn't came through, I have added it now and it should make a lot more sense. – Adetya Aggarwal Aug 31 '20 at 14:12

0 Answers0