I’m sure this is a duplicate, but the answer is simple:
sort(table(variable),decreasing=TRUE)[1:3]
More Related Contents:
- Count number of rows per group and add result to original data frame
- Counting the number of elements with the values of x in a vector
- Add count of unique / distinct values by group to the original data
- Include levels of zero count in result of table()
- Count number of occurences for each unique value
- Create counter within consecutive runs of values
- How can I count runs in a sequence?
- Count non-NA values by group [duplicate]
- Count number of rows by group using dplyr
- How to count the frequency of a string for each row in R
- Extend contigency table with proportions (percentages)
- Cumulative count of each value [duplicate]
- Find the most frequent value by row
- Tidyr how to spread into count of occurrence [duplicate]
- Count number of columns by a condition (>) for each row
- Count unique values for every column
- How can I count the number of NAs per group?
- R: replace the whole part of a number but keep the decimal part unchanged
- Why is the parallel package slower than just using apply?
- Scale a series between two points
- How to replace NA values in a table for selected columns
- R: gsub, pattern = vector and replacement = vector
- Adding space between bars in ggplot2
- Align plot areas in ggplot
- Error in plot.window(…) : need finite ‘xlim’ values
- multithreading with R?
- Add column with order counts
- Efficient calculation of matrix cumulative standard deviation in r
- Confused by …()?
- Shiny – observe() triggered by dynamicaly generated inputs