问题
I need to use the cut function to divide into irregular, uneven breaks.
I need to cut into ranges such as 1 to 15, 16 to 19, 20 to 45... ect. Though I do not know how to do this or if it is possible. Please help!
回答1:
?cut
is a good first step...
Here is a sample from which you can build:
# 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
来源:https://stackoverflow.com/questions/33542885/cut-function-making-irregular-cuts-in-r