我需要对一些频率进行分类,其最低和最高范围趋于无限。示例:
少于1000
1001至5000
5001至10000
10001至50000
超过50000
我该如何使用R?
谢谢。
答案 0 :(得分:0)
这应该作为示例解决方案。
# Data generated
dt<-data.table("Frequency" = sample(x = 1:100000,size = 40))
# New column appended with the Classification
dt[,Class := cut(x = dt$Frequency,breaks = c(-Inf,1000,5000,10000,50000,Inf),labels = c("C1","C2","C3","C4","C5"),right = T)]
希望有帮助