Re: [R] "bucketing" observations

2009-04-06 Thread Dan Dube
great! the "cut" function was exactly what i needed. thank you both! > -Original Message- > From: Dimitris Rizopoulos [mailto:d.rizopou...@erasmusmc.nl] > Sent: Monday, April 06, 2009 4:01 PM > To: Dan Dube > Cc: r-help@r-project.org > Subject: Re:

Re: [R] "bucketing" observations

2009-04-06 Thread Dimitris Rizopoulos
try this: dat <- data.frame(vals = rnorm(1000)) breaks <- quantile(dat$vals, seq(0, 1, .1)) dat$bucket <- cut(dat$vals, breaks, labels = FALSE, include.lowest = TRUE) I hope it helps. Best, Dimitris Dan Dube wrote: is there a better way to bucket observations into more-or-less evenly sized

Re: [R] "bucketing" observations

2009-04-06 Thread Bert Gunter
Subject: [R] "bucketing" observations 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:len

[R] "bucketing" observations

2009-04-06 Thread Dan Dube
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) {