is there a better way to bucket observations into more-or-less evenly
sized buckets than this?  it seems like this must be a common operation:

dt = data.frame(points=rnorm(1000),bucket=NA)

breaks = quantile(dt$points,seq(0:1,.1))
for (i in 2:length(breaks)) {
        if (i == 2) {
                ind = which(dt$points >= breaks[i-1] & dt$points <=
breaks[i])
        } else {
                ind = which(dt$points > breaks[i-1] & dt$points <=
breaks[i])
        }
        dt$bucket[ind] = i-1
}

thanks!

______________________________________________
R-help@r-project.org 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