Hi everyone,
Below I am illustrating an example where I am wanting to replace my NA values with corresponding scores. I have provided a second table of what I am looking to accomplish. Risk 4 demonstrates where I have all NA values, which will not get replaced. Risk numbers 5 and 6 show that my data might not have five years for every risk. Risk 7 is a very rare example where I would be fine if we only develop a solution to the other risk numbers. Thanks.
Solution
Risk Year Score Risk Year Score
1 2015 867 1 2015 867
1 2016 994 1 2016 994
1 2017 634 1 2017 634
1 2018 696 1 2018 696
1 2019 NA 1 2019 696
2 2015 NA 2 2015 964
2 2016 NA 2 2016 964
2 2017 964 2 2017 964
2 2018 863 2 2018 863
2 2019 997 2 2019 997
3 2015 NA 3 2015 777
3 2016 NA 3 2016 777
3 2017 777 3 2017 777
3 2018 856 3 2018 856
3 2019 NA 3 2019 856
4 2015 NA 4 2015 NA
4 2016 NA 4 2016 NA
4 2017 NA 4 2017 NA
4 2018 NA 4 2018 NA
4 2019 NA 4 2019 NA
5 2017 803 5 2017 803
5 2018 929 5 2018 929
5 2019 797 5 2019 797
6 2016 950 6 2016 950
6 2017 NA 6 2017 950
7 2015 871 7 2015 871
7 2016 NA 7 2016 871
7 2017 NA 7 2017 871
7 2018 699 7 2018 699
7 2019 620 7 2019 620