0

I want to apply the cast() function to this df. In the df there are 2081 different unique 'Variables'. I do not know how to get each of them to be a column with its 'Value' as the content of that column. Also, the seasons are from 2010 - 2018, so there are multiple copies of "Player.Name". Any help is greatly appreciated.

Thank you

     Player.Name   Season       Variable               Value
      <fctr>       <int>        <fctr>                 <fctr>

1   Robert Garrigus 2010    Driving Distance - (ROUNDS) 71
2   Bubba Watson    2010    Driving Distance - (ROUNDS) 77
3   Dustin Johnson  2010    Driving Distance - (ROUNDS) 83
4   Brett Wetterich 2010    Driving Distance - (ROUNDS) 54
5   J.B. Holmes     2010    Driving Distance - (ROUNDS) 100
6   John Daly       2010    Driving Distance - (ROUNDS) 63
...
  • We can have a group by date range and then apply the cast , You have a range of date in seasons and how do you want to handle the value for It ? – redhatvicky Nov 21 '19 at 14:45
  • 2
    I'd recommend checking out the new tidyr functions pivot_longer() and pivot_wider(). You can read more at the tidyr website https://tidyr.tidyverse.org/articles/pivot.html – kputschko Nov 21 '19 at 14:46
  • redhatvicky, if there was only one year, if I filtered by `Season` ==2018? Could what I originally asked be possible then? – Vinnie Palazeti Nov 21 '19 at 14:51

0 Answers0