Hi, I am trying to apply linear interpolation on a column EVI of a dataframe df. However, the column EVI has three distinct year classes (2015, 2016 and 2017). The code below (na.approx) applies to the whole column. I want to apply the linear interpolation function on different years (2015, 2016, 2017) for a single column.
# This function applies the linear interpolation on the whole column df$EVI<- na.approx(df$EVI, na.rm= FALSE, maxgp =Inf, rule =2) #I want apply the function on different years for 2015, 2016 and 2017