📅  最后修改于: 2022-03-11 14:58:45.553000             🧑  作者: Mango
df <- data.frame(name=c("r", "h", "s", "l", "e", "m"), value=c(35,20,16,40,23,40))
# get categories
df$groups <- cut(df$value, breaks=c(0,21,30,Inf))
# calculate group counts:
table(cut(df$value, breaks=c(0,21,30,Inf)))