Search code examples
rggplot2histogramfrequency

How to plot frequency of occurrence with condition


I have a data set with industry names. when I plot the frequency, it gives me

see picture.

Is there any way to plot the frequency of occurrence but only if the frequency is more than a certain number let's say 10.

I guess what I want is plot the count with a condition.

here is my code:

ggplot(see, aes(x=industry, y=freq)) + 
    geom_bar(stat="identity", colour="black", fill="white") + 
    xlab("") + ylab("")

Solution

  • Just filter the data before plotting, as below,

    see %>% filter(freq >= 10) %>%
    ggplot(data = .,aes(x=industry, y=freq)) + 
        geom_bar(stat="identity", colour="black", fill="white") + 
        xlab("") + ylab("")