I would like to calculate the maximum value of winshares based on the last two years by player (i.e., full name). For example, if I have a player named Aaron Brooks (in the table), for 2010 I would want the value 3.6 because it is the max of winshares of the 2008 and 2009 seasons. It gets tricky because sometimes the player plays for two teams in one year. I created a column called "Variable I am trying to create" to illustrate what variable I want to create. Thank you for your help.
fullname | team | stint | winshares | seasonyr | Variable I am trying to create |
Aaron Brooks | Hou | 1 | 1.4 | 2008 | . |
Aaron Brooks | Hou | 1 | 3.6 | 2009 | 1.4 |
Aaron Brooks | Hou | 1 | 5.5 | 2010 | 3.6 |
Aaron Brooks | Pho | 2 | 1.1 | 2011 | 5.5 |
Aaron Brooks | Hou | 1 | 1.1 | 2011 | 5.5 |
Aaron Brooks | Hou | 2 | .9 | 2013 | 1.1 (didn't play in 2012) |
Aaron Brooks | Sac | 1 | .9 | 2013 | 1.1 (didn't play in 2012) |
Aaron Brooks | Hou | 2 | 2.1 | 2014 | .9 (didn't play in 2012) |
Aaron Brooks | Den | 1 | 2.1 | 2014 | .9 (didn't play in 2012) |
Aaron Brooks | Chi | 1 | 3.3 | 2015 | 2.1 |
Aaron Brooks | Chi | 1 | .9 | 2016 | 3.3 |
Aaron Brooks | Chi | 1 | 1.2 | 2017 | 3.3 (max of 2015 and 2016) |
Comment