How can I exclude hermaphroditic and none from this facet wrap?

Viewed 24
ggplot(starwars, aes(x=height, fill=sex)) + 
    geom_density(fill="skyblue") +
    theme_bw() +
    facet_wrap( ~ sex, scales = "free_y")

I don't want hermaphroditic or none to show up, but I can't seem to get rid of them. Thanks.

1 Answers

This should do what you want:

ggplot(data=subset(starwars, sex!="hermaphroditic" & sex!="none"), aes(x=height, fill=sex)) + 
    geom_density(fill="skyblue") +
    theme_bw() +
    facet_wrap( ~ sex, scales = "free_y")
Related