Tuesday, February 02, 2010

Piece-wise Aggregate Approximation

Piece-wise Aggregate Approximation in R


paa <- function(data, window) {
ret = NULL
start = 1
while (start <= nrow(data)) {
end = min(start + window - 1, nrow(data))
ret = rbind(ret, colMeans(data[start:end,]))
start = start + window
}
return(ret)
}

No comments: