Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

INTRODUCTION

The goal of patchwork is to make it simple to combine separate ggplots into the same graphic. It tries to solve the same problem as gridExtra::grid.arrange() and cowplot::plot_grid, but using an API that incites exploration and iteration.

Look at the examples given and try to understand the logic behind them. Then, try to solve the exercises below by using R without looking at the answers. Then, check the solutions to check your answers.

Exercise 1

Create a scatter-plot object of `mtcars` between `mpg` and `disp`.

Exercise 2

Create a box-plot object of `mtcars` between `gear` and `disp` grouped by `gear`.

Exercise 3

Compose those two objects into one graph.

Exercise 4

Repeat the previous process but in one plotting operation.

Exercise 5

Display the composed graph in one column with the two graphs, one below the other.

Exercise 6

Set the graph on top to have two times the size of the graph at the bottom.

Exercise 7

Exercise 8

Create two objects of your choice (`p3`,` p4`) and display all of your four objects in nested mode by putting `p4` on top` p1` and `p2` and `p3` at the bottom (nested one below the other.)

Exercise 9

Now, put the two nested plots next to each other.

Exercise 10

Finally, display `p4` in one column and the rest of your objects in another.