September 2018
Beginner
206 pages
4h 27m
English
One handy feature to know about is an additional aesthetic layer, coord_flip(). Given that R functions are named in an informative way, it probably does more or less exactly what you'd think.
Let's return to our boxplot example from mtcars, which shows the distribution of mpg by the number of cylinders. We modify the code and add coord_flip() as follows:
ggplot(mtcars, aes(cylfactor, mpg)) + geom_boxplot() + coord_flip()
The output we get will be as shown in the following screenshot:

We see that cylfactor is now on the y-axis and mpg is on the x-axis, and the boxplots can flip. coord_flip() can be implemented on other ...
Read now
Unlock full access