mutate+c_across + matching with case_when

fm_2 accounts for the fact that if theres no match, you cant report the first match. Also as in the data the matches align with the year numbers its easy to go from the column that matched number to the year name by adding 1.

If you have significantly different data so that you think the solution would need to be different and you would like additional help, i recommend you make a reprex.

1 Like