Take difference between first and last observations in a row, where each row is different
问题 I have data that looks like the following: Region X2012 X2013 X2014 X2015 X2016 X2017 1 1 10 11 12 13 14 15 2 2 NA 17 14 NA 23 NA 3 3 12 18 18 NA 23 NA 4 4 NA NA 15 28 NA 38 5 5 14 18.5 16 27 25 39 6 6 15 NA 17 27.5 NA 39 The numbers are irrelevant here but what I am trying to do is take the difference between the earliest and latest observed points in each row to make a new column for the difference where: Region Diff 1 (15 - 10) = 5 2 (23 - 17) = 6 and so on, not actually showing the