Moving Average

Creating moving average of (+/-) 15 Day
library(zoo) names = colnames(Temp[3:ncol(Temp)]) Temp_MA[paste0(names, "_MA")] = lapply(Temp_MA[,3:ncol(Temp_MA)], function(a) rollapply(a, FUN = mean, width = 31, fill = NA, na.rm = TRUE))