I\'m trying to use R to calculate the moving average over a series of values in a matrix. The normal R mailing list search hasn\'t been very helpful though. There doesn\'t s
vector_avg <- function(x){ sum_x = 0 for(i in 1:length(x)){ if(!is.na(x[i])) sum_x = sum_x + x[i] } return(sum_x/length(x)) }