I have a data frame in which I want to apply rollapply function. I can have up to 5% of NAs within a column.
I would like to omit the NA but it seems to me there is no na.omit. Alternatively I would be happy to fill the missing value with last known value in the column.
I don't see how to do that with ??rollapply
Would anyone have an idea? Many thanks,
Vincent
Edit: The function I am working on is:
function(TableVolume,n){
TableM = TableVolume
for (i in 2:ncol(TableVolume)){TableM[,i]=rollapply(TableVolume[,i],n,FUN=mean,partial=TRUE}
TableM=TableM[n:nrow(TableVolume),]
return(TableM)
}