cut.quantile <- function(x, N, use.ppoints=TRUE) {
  qq <- if (use.ppoints) c(0,ppoints(N-1),1)
  else seq(0, 1, 1/N)
  breaks <- quantile(x, qq)
  breaks[1] <- breaks[1] - 1 
  breaks[N+1] <- breaks[N+1]+1
  cut(x, breaks)
}

tmpT <- cut.quantile(rnorm(100), 10, TRUE)
table(tmpT)
tmpF <- cut.quantile(rnorm(100), 10, FALSE)
table(tmpF)

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to