How do I get the most frequent entry in R?
For example if I would have data in two columns:
Name-City
A-New York
A-New York
A-Montreal
A-New York
B-Chicago
B-Chicago
B-New York
B-Detroit
I would like to get a dataframe with:
Name-City
A-New York
B-Chicago
So it should have every unique entry in "Name" with the most frequent entry in "City".
My idea would be something like:
df %>%
group_by(Name) %>%
count(City)