September 2018
Beginner
206 pages
4h 27m
English
Facet wrapping and gridding can be applied to any ggplot, not just bar charts. Facet wrapping will split the base ggplot (which, here, is the count of cars with each number of cylinders) by a second variable, which, here, will be the number of gears, generating three plots. The code for this is as follows:
ggplot(mtcars, aes(cylfactor)) + geom_bar() + facet_wrap(~gear)
We can see that each of the three numbers of gears (3, 4, 5) have a bar chart for the count of the number of cars with each of the three types of cylinders (here, cylfactor, with values 4, 6, 8). Facet wrapping can be applied to any of the ggplots, though it may sometimes look strange, which can be mitigated with facet gridding.
Facet gridding is ...
Read now
Unlock full access