[R] rollapply() to portions of a matrix

rcoder mpdotbook at gmail.com
Thu Jul 31 21:36:46 CEST 2008

Hi everyone,

I have a rollapply statement that applies a function, in steps, over a data
matrix as follows:

#Code start
testm<-rollapply(mat, 100, by=100, min, na.rm=F)
#Code end

This moves down matrix 'mat' and calculates the minimum value over a 100 row
range, every 100 rows (i.e. no overlaps). NAs are not removed.

I want to modify this statement somehow so that the rollapply() stops at a
certain row in the matrix: i.e. it applies from the top, as instructed by
the statement, but only to a certain row in the matrix. Can anyone suggest a
way to do this using the additional arguments in the parentheses? One way
would be to introduce an if statement, but is this the only way?


View this message in context: http://www.nabble.com/rollapply%28%29-to-portions-of-a-matrix-tp18761906p18761906.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list