I want to calculate the R-Squared of each of the stats in columns 3-5 (targets, receptions, and yards) and how it correlates to following-year fpts. Below is a sample of the type of data I'm working with:
player | year | targets | receptions | yards | fpts |
---|---|---|---|---|---|
Michael Gallup | 2017 | 113 | 66 | 1107 | 147 |
D.J. Moore | 2017 | 135 | 87 | 1175 | 144 |
Robert Woods | 2017 | 139 | 90 | 1134 | 143 |
Calvin Ridley | 2017 | 93 | 63 | 866 | 134 |
Terry McLaurin | 2017 | 93 | 58 | 919 | 134 |
Tyler Boyd | 2017 | 148 | 90 | 1046 | 133 |
Deebo Samuel | 2017 | 81 | 57 | 802 | 132 |
Michael Gallup | 2018 | 91 | 62 | 779 | 132 |
D.J. Moore | 2018 | 89 | 58 | 860 | 130 |
Robert Woods | 2018 | 127 | 83 | 997 | 130 |
Calvin Ridley | 2018 | 100 | 58 | 900 | 129 |
Terry McLaurin | 2018 | 133 | 74 | 1035 | 127 |
Tyler Boyd | 2018 | 97 | 66 | 869 | 124 |
Deebo Samuel | 2018 | 84 | 48 | 740 | 122 |
Michael Gallup | 2019 | 122 | 78 | 833 | 120 |
D.J. Moore | 2019 | 106 | 67 | 778 | 118 |
Robert Woods | 2019 | 105 | 54 | 627 | 118 |
Calvin Ridley | 2019 | 90 | 49 | 1001 | 112 |
Terry McLaurin | 2019 | 96 | 52 | 779 | 110 |
Tyler Boyd | 2019 | 90 | 47 | 775 | 110 |
Deebo Samuel | 2019 | 92 | 59 | 680 | 104 |
I'd like to get it so it appears like this, with the "next_year_fpts" column
player | year | targets | receptions | yards | fpts | next_year_fpts |
---|---|---|---|---|---|---|
Michael Gallup | 2017 | 113 | 66 | 1107 | 147 | 132 |
D.J. Moore | 2017 | 135 | 87 | 1175 | 144 | 130 |
Robert Woods | 2017 | 139 | 90 | 1134 | 143 | 130 |
Calvin Ridley | 2017 | 93 | 63 | 866 | 134 | 129 |
Terry McLaurin | 2017 | 93 | 58 | 919 | 134 | 127 |
Tyler Boyd | 2017 | 148 | 90 | 1046 | 133 | 124 |
Deebo Samuel | 2017 | 81 | 57 | 802 | 132 | 122 |
Michael Gallup | 2018 | 91 | 62 | 779 | 132 | 120 |
D.J. Moore | 2018 | 89 | 58 | 860 | 130 | 118 |
Robert Woods | 2018 | 127 | 83 | 997 | 130 | 118 |
Calvin Ridley | 2018 | 100 | 58 | 900 | 129 | 112 |
Terry McLaurin | 2018 | 133 | 74 | 1035 | 127 | 110 |
Tyler Boyd | 2018 | 97 | 66 | 869 | 124 | 110 |
Deebo Samuel | 2018 | 84 | 48 | 740 | 122 | 104 |
Michael Gallup | 2019 | 122 | 78 | 833 | 120 | NA |
D.J. Moore | 2019 | 106 | 67 | 778 | 118 | NA |
Robert Woods | 2019 | 105 | 54 | 627 | 118 | NA |
Calvin Ridley | 2019 | 90 | 49 | 1001 | 112 | NA |
Terry McLaurin | 2019 | 96 | 52 | 779 | 110 | NA |
Tyler Boyd | 2019 | 90 | 47 | 775 | 110 | NA |
Deebo Samuel | 2019 | 92 | 59 | 680 | 104 | NA |
This way I'll be able to calculate R-Squared for the targets, receptions, etc. in year x compared to the fpts in year x+1. I'll have several years of data with many more players, so looking for quick and reproducible way to make my data the way that I need it.