I have a dataframe that looks like this, where each observation is the size of a school's enrollment:
Year1 Year2 Year3 Year4 Year5 Year6 Year7 Slope
School1 89 87 74 64 0 0 0
School2 100 99 90 87 83 80 0
School3 65 30 0 0 0 0 0
I'm trying to calculate the slope of enrollment declines in the year leading up to the closure of the school, with the output ending up in the "slope" column.
More generally, I'm trying to calculate the slope of a series of observations up until the first "stop" value (in this case, zero).
Thanks in advance!