答案 0 :(得分:0)
要按给定的断点对C1列进行分组,R中有cut
命令:
C <- data.frame(C1=runif(30))
C$group <- cut(C$C1, c(0, .2, .4, .6, .8, 1))
print(C)
可以使用table
显示每个组/ bin中的点数:
table(C$group)
答案 1 :(得分:0)
m<- seq(3,13.5,0.5)
C$bin_grouping <- cut(C$C1,m)
#Once i have Bin_grouping further i Used Dplyr Package as such to sum C2 Column
by_bin<-group_by(C,bin_grouping)
new_C <-summarise(by_bin,new_C2=sum(C2, na.rm = TRUE),Count=n())