I’m sure this is a duplicate, but the answer is simple:
sort(table(variable),decreasing=TRUE)[1:3]
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
- Count number of occurences for each unique value
- Create counter within consecutive runs of values
- Include levels of zero count in result of table()
- How can I count runs in a sequence?
- Count non-NA values by group [duplicate]
- Count number of rows by group using dplyr
- Count number of columns by a condition (>) for each row
- 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]
- How can I count the number of NAs per group?
- Find the most frequent value by row
- Apply a function to every specified column in a data.table and update by reference
- How to select the rows with maximum values in each group with dplyr? [duplicate]
- Remove ‘a’ from legend when using aesthetics and geom_text
- Fixing the order of facets in ggplot
- Plot labels at ends of lines
- Read multiple CSV files into separate data frames
- Repeat rows of a data.frame [duplicate]
- Efficient way to rbind data.frames with different columns
- Intelligent point label placement in R
- Control ggplot2 legend look without affecting the plot
- Finding percentage in a sub-group using group_by and summarise
- Creating multiple graphs based upon the column names
- How to set up rselenium for R?
- Avoid clipping of points along axis in ggplot
- Split text string in a data.table columns
- How to use reference variables by character string in a formula?
- Add “filename” column to table as multiple files are read and bound
- ggplot2: change order of display of a factor variable on an axis
- how to insert new line in R shiny string
- Randomly insert NAs into dataframe proportionaly
- How do I map a vector of values to another vector with my own custom map in R [duplicate]
- R ggplot2 merge with shapefile and csv data to fill polygons
- Can I replace NAs when joining two data frames with dplyr?
- Replace NA values by row means
- lm function in R does not give coefficients for all factor levels in categorical data
- How to delete columns that contain ONLY NAs?
- Eliminating NAs from a ggplot
- What does the capital letter “I” in R linear regression formula mean?
- How to prevent scientific notation in R? [duplicate]
- Which is the best method to apply a script repetitively to n .csv files in R?
- change background and text of strips associated to multiple panels in R / lattice
- dplyr broadcasting single value per group in mutate
- add image in title page of rmarkdown pdf
- Is there an R function to reshape this data from long to wide?
- Remove pattern from string with gsub