Is there any way to force zoo::rollmean function to return a vector that is the same length as it's input? (or maybe use other function?)
input = cbind(c(3,7,3,5,2,9,1,4,6,4,7,3,7,4)) library(zoo) output = cbind(rollmean(input,4)) print(input) print(output) output: [,1] [1,] 3 [2,] 7 [3,] 3 [4,] 5 [5,] 2 [6,] 9 [7,] 1 [8,] 4 [9,] 6 [10,] 4 [11,] 7 [12,] 3 [13,] 7 [14,] 4 [,1] [1,] 4.50 [2,] 4.25 [3,] 4.75 [4,] 4.25 [5,] 4.00 [6,] 5.00 [7,] 3.75 [8,] 5.25 [9,] 5.00 [10,] 5.25 [11,] 5.25 but when I try to cbind it: Error in cbind(input, output) : number of rows of matrices must match (see arg 2) Calls: print -> cbind Execution halted I'd like to use a function that would be smart enough and do not give up if it doesn't get data on