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:
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
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
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) {
4 matches
Mail list logo