I am having the issue where when I try to facet data in ggplot to make bar graphs, not all data gets added into the correct facets...
I have a very large dataset, so it's inconvenient to share, but I will post examples of what one facet should actually look like.
So here is my code:
ggplot(data=data,aes(x=data$practice_cat,y=data$pct_pop)) +
geom_bar(stat='identity') + facet_grid(type ~ size_f) + coord_flip()
And this is the plot that I get:
However, the faceting is not true to the data. It seems like facet_grid is attributing certain rows to the incorrect facet. For example, for the facet total and > 10 NPIs, the graph should look more like this:
How do I fix this?