cut2
```# Make some data
set.seed(1)
x <- dataframe(raw=rnorm(1000, 100, 15))
```
```# Cut into 4 groups, specifying the top of each band (except the last... which is ended to include all data)
x\$new <- cut2(x\$raw, c(70,120,130))
table(x\$new)

[ 54.9, 70.0) [ 70.0,120.0) [120.0,130.0) [130.0,157.2]
33           868            72            27
```
```# Make 3 equal sized groups
x\$new <- Hmisc::cut2(x\$raw, g=3)
# Set sane level names
levels(x\$new)<-c("low","med","high")
table(x\$new)
```
 ~low med high 334 333 333
``````plyr::ddply(x, "new", summarise,
mean   = round(mean(raw),2),
n = length(raw)
)```
```

 new mean n 1 low 84.97 334 2 med 100.04 333 3 high 115.79 333
```# Make groups, where the smallest group is m or more subjects
table(cut2(x, m=200)) # group x into intevals with at least 50 obs.
[ 0.131, 20.2) [20.168, 39.8) [39.784, 59.6) [59.645, 79.7) [79.731,100.0]
200            200            200            200            200
```
page revision: 8, last edited: 09 Sep 2012 11:33