Skip to content
Prev 279726 / 398506 Next

a weird "cut" question

You could use quantile() to create the breakpoints
  > x <- c(47677, 47602, 47678, 47905, 47909, 47906, 47605, 47673, 47607)
  > cutX <- cut(x, breaks=quantile(x, (0:3)/3), include.lowest=TRUE)
  > cutX
  [1] (4.77e+04,4.78e+04] [4.76e+04,4.77e+04] (4.77e+04,4.78e+04] (4.78e+04,4.79e+04]
  [5] (4.78e+04,4.79e+04] (4.78e+04,4.79e+04] [4.76e+04,4.77e+04] (4.77e+04,4.78e+04]
  [9] [4.76e+04,4.77e+04]
  Levels: [4.76e+04,4.77e+04] (4.77e+04,4.78e+04] (4.78e+04,4.79e+04]
  > table(cutX)
  cutX
  [4.76e+04,4.77e+04] (4.77e+04,4.78e+04] (4.78e+04,4.79e+04] 
                  3                   3                   3

This will fail if there are only 2 distinct values in the dataset.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com