统计频率和频数

来源:互联网 发布:京颐集团 知乎 编辑:程序博客网 时间:2024/05/03 03:23

使用内置的mtcars

统计频数

table(mtcars$gear)

统计频率

paste0(round(prop.table(table(mtcars$gear)),2)*100,’%’)

统计频率的另一种方法,使用arregate

total<-length(mtcarsgear)b<aggregate(mtcarsgear,by=list(mtcarsgear),length)bx/total
cbind(b,b$x/total)

0 0
原创粉丝点击