切割功能:在 R 中进行不规则切割

Cut Function: Making Irregular cuts in R

我需要使用剪切功能来分割不规则、不均匀的断点。

我需要切割成 1 到 15、16 到 19、20 到 45...等范围。虽然我不知道该怎么做或者是否可能。请帮忙!

?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