Pages

3/03/2011

A simple downsample function for vectors in R

Archive, nothing fancy about this function


downsample <- function (v, N){ # v is the input vector, and keep every N sample
seed <- c(TRUE,rep(FALSE,N-1))
cont <- rep(seed,ceiling(length(v)/N))[1:length(v)]
return(v[which(cont)])
}

No comments:

Post a Comment