I would like to use the rollapply function from the zoo package in R to calculate a moving IQR, but this fails when missing data (NA's) are reached in my data series.
data_series <- c(4,7,4,7,3,6,5,8,5,NA,9,0,5,8,1,3,6,5)
roll_iqr <- rollapply(data_series, width = 5, fill = NA, FUN = IQR)
Error in quantile.default(as.numeric(x), c(0.25, 0.75), na.rm = na.rm, :
missing values and NaN's not allowed if 'na.rm' is FALSE
Is there a way to tell the rollapply function to include the na.rm = T argument that would normally be part of the IQR function?