根据R中的频率排序 [英] Sort based on Frequency in R
本文介绍了根据R中的频率排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
输入数据框的结构
ds= structure(list(MSISDN = c(800, 800, 783,
975, 800)), .Names = "Number", row.names = c(NA,
-5L), class = "data.frame")
需要一个简单的输出,如下所示(无法添加单个中断)
Need a simple output which looks like below (not able to add single break)
数字频率
800 3
975 1
783 1
推荐答案
从管理员程序中检出Tabyl函数.它完成了您想要的任务,再加上一点
Check out Tabyl function from janitor package. It does the task that you want plus a bit more
library(janitor)
ds <- structure(list(MSISDN = c(800, 800, 783,975, 800)), .Names = "Number", row.names = c(NA,-5L), class = "data.frame")
tabyl(ds$Number)
这篇关于根据R中的频率排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文