0

I would like to make a table for 5 top frequency of countries in a dataset on car production.

I have tried different forms of frequency counts such as:

library(dplyr)

mtcars %>%
   group_by(cyl) %>%
   summarize(count(cyl)) 

However, I don't understand how I can display only top 5 production countries. Should I make a frequency list first and then use that to create a table for the top 5 frequency?

Also, the top 5 frequency is NA. I know how to remove those rows in a data frame, but not in the code for the frequency table...

I understand that someone thought this was similar to another question. As explained in my comment before this question was closed, I'm looking for the top count, not the top value. Also, I have tried all the solutions proposed, and it did not work.

Just to reiterate:I'm a complete beginner, and I apologise if what I'm asking is fundamental and that I am asking for a bit of handholding. I would still ask that this question is kept open.

Any help is much appreciated.

candypox
  • 1
  • 3
  • 1
    Does this help: [Select the top N values by group](https://stackoverflow.com/questions/14800161/select-the-top-n-values-by-group)? – Quinten Oct 02 '22 at 09:20
  • I don't think so, because I'm not looking for values, but rather counts of countries. So what I'm trying to measure is the number of cars produced per country and sorted per frequency with the largest producers on top. – candypox Oct 02 '22 at 10:01

0 Answers0