Overview of this book

R Graph Essentials
Credits
www.PacktPub.com
Preface
Free Chapter
Base Graphics in R – One Step at a Time
Creating Graphs with ggplot
Index

Creating scatterplot matrices

Scatterplot matrices of bivariate data are helpful to identify relationships between variables in a dataset. We can create scatterplot matrices using `pairs()` and the tilde sign, along with plus signs that instruct R to include the desired variables:

```pairs(~WEIGHT_1 + WEIGHT_2 + HEIGHT, data=T,
main="Scatterplot Matrix of Medical Data")
```

This syntax gives the following matrix:

If we want a smooth curve (LOWESS) in each bivariate plot, we include the argument `panel=panel.smooth`:

```pairs(~WEIGHT_1 + WEIGHT_2 + HEIGHT, data=T,
main="Scatterplot Matrix of Medical Data", panel = panel.smooth)
```

The matrix obtained is as follows:

We see a strong linear relationship between `WEIGHT_1` and `WEIGHT_2`, and curved relationships between those variables and `HEIGHT`.

Writing functions to create graphs

Why not create functions to draw graphs? Here's a function for histograms of vectors of data with standard titles and labels. It allows you to add numbers to the title and axis labels and...