O'Reilly logo

Graphing Data with R by John Jay Hilfiger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16. Scatter plot Matrices and Corrgrams

Scatter plot Matrix

When faced with many quantitative variables, it sometimes helps to look at the relationships of each of the possible pairs of variables first. To avoid making you type a plot() command for each of the combinations, R provides a shortcut command, pairs(), which will do the same thing. Furthermore, pairs() puts all the plots on the same page so that they can be compared quite easily. The result is called a scatter plot matrix. We will use the scatter plot matrix to study the relationships among member characteristics of various church groups.

A long line of research on American religious life has shown that weekly attendance and membership seem to be related to a church’s strictness. Iannaccone (1994) discusses this research and gives an interesting dataset showing several variables for each of 18 religious denominations. You can find the data in ex1713 from the Sleuth2 package. Let’s take a look:

> library(Sleuth2)
> attach(ex1713)
> head(ex1713)

        Denomination Distinct Attend NonChurch StrongPct AnnInc
1     American Baptist    2.5   25.6      1.01      50.6  24000
2    Assemblies of God    4.8   35.4      0.68      58.6  27100
3             Catholic    3.0   26.4      1.43      40.0  32900
4  Disciples of Christ    2.1   24.3      2.58      47.0  28600
5            Episcopal    1.1   17.3      1.93      32.0  39000
6 Evangelical Lutheran    2.7   23.0      1.71      41.5  33700

To see the codebook for this data, type:

> ?ex1713

Here’s a brief summary of the codebook:

Distinct
The distinctiveness/strictness of discipline, on a seven-point ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required