2015-11-05 49 views

回答

3

?cut是一个良好的开端......

这里是你可以建立一个样本:

# create a long vector that you want to cut 
z <- rnorm(10000) 
# create a vector with irregular breakpoints 
breaks <- c(-6, -1, 1, 3, 6) 
# cut the long vector, look at the `table()`d result 
table(cut(z, breaks)) 
    (-6,-1] (-1,1] (1,3] (3,6] 
    1572 6806 1608  14