Sort based on Frequency in R
问题 Structure of input dataframe 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) Num Freq 800 3 975 1 783 1 回答1: 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