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)
}

Monday, February 01, 2010

Removing ^M characters (windows line endings) using VIM editor

Removing \r\n (windows line endings) in VIM editor

In vi, you can remove the carriage return ( ^M ) characters with the following command:

:1,$s/^M//g


Note: To input the ^M character, press Ctrl-v , then press Enter or return.