Question

I have read the document, but can't figure it out. Suppose there are data like below:

x=matrix(1:60,nrow=10)
x
      [,1] [,2] [,3] [,4] [,5] [,6]
 [1,]    1   11   21   31   41   51
 [2,]    2   12   22   32   42   52
 [3,]    3   13   23   33   43   53
 [4,]    4   14   24   34   44   54
 [5,]    5   15   25   35   45   55
 [6,]    6   16   26   36   46   56
 [7,]    7   17   27   37   47   57
 [8,]    8   18   28   38   48   58
 [9,]    9   19   29   39   49   59
[10,]   10   20   30   40   50   60

When I use rollapply on x and set by.column equal to FALSE, it give me a string of number, but I don't know how it was calculate, can someone help?

rollapply(x,3,mean,fill=NA,align="right",by.column=FALSE)
[1] NA NA 27 28 29 30 31 32 33 34

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top