@JKSheard found two issues here. First, if the years are 1:x the function gets confused as it is expecting years YYYY:YYYY (though this is not stated anywhere).
Second the function returns all data plus the mean, but mean is not always appropriate. We don't want users to blindly use the mean just because we provided it. I will add the median to the returned object which will hopefully make users think about what the appropriate statistic is.
@JKSheard found two issues here. First, if the years are 1:x the function gets confused as it is expecting years YYYY:YYYY (though this is not stated anywhere).
Second the function returns all data plus the mean, but mean is not always appropriate. We don't want users to blindly use the mean just because we provided it. I will add the median to the returned object which will hopefully make users think about what the appropriate statistic is.