Hello all,
I would simply like to obtain in my plot the 3 top categories (with the highest frequencies) and have all the others in a single "Other" category where their frequencies are combined.
I know how to get the plot where only the top 3 is displayed but I can't create the "Other" category
library(dplyr)
df <- data.frame(
type=c("car","bike","horse","boat","yacht","train"),freq=c(20,2,5,60,11,10))
#Plot
top_n(df, n=3, freq) %>%
ggplot(., aes(x=type, y=freq))+
geom_bar(stat='identity')
If someone knows how to figure it out
Thanks a lot
Hersh