Learn R Programming

psych (version 1.0-77)

pairs.panels: SPLOM, histograms and correlations for a data matrix

Description

Adapted from the help page for pairs, pairs.panels shows a scatter plot of matrices (SPLOM), with bivariate scatter plots below the diagonal, histograms on the diagonal, and the Pearson correlation above the diagonal. Useful for descriptive statistics of small data sets. If lm=TRUE, linear regression fits are shown for both y by x and x by y. Correlation ellipses are also shown.

Usage

pairs.panels(x, smooth = TRUE, scale = FALSE, density=TRUE,ellipses=TRUE,digits = 2, pch = 20,lm=FALSE, jiggle=FALSE, ...)

Arguments

x
a data.frame or matrix
smooth
TRUE draws loess smooths
scale
TRUE scales the correlation font by the size of the absolute correlation.
density
TRUE shows the density plots as well as histograms
ellipses
TRUE draws correlation ellipses
lm
Plot the linear fit rather than the LOESS smoothed fits.
digits
the number of digits to show
pch
The plot character (defaults to 20 which is a '.').
jiggle
Should the points be jittered before plotting?
...
other options for pairs

Value

  • A scatter plot matrix (SPLOM) is drawn in the graphic window. The lower off diagonal draws scatter plots, the diagonal histograms, the upper off diagonal reports the Pearson correlation (with pairwise deletion).

    If lm=TRUE, then the scatter plots are drawn above and below the diagonal, each with a linear regression fit. Useful to show the difference between regression lines.

Details

Shamelessly adapted from the pairs help page. Uses panel.cor, panel.cor.scale, and panel.hist, all taken from the help pages for pairs. Also adapts the ellipse function from John Fox's car package.

pairs.panels is most useful when the number of variables to plot is less than about 6-8. It is particularly useful for an initial overview of the data.

See Also

pairs

Examples

Run this code
pairs.panels(attitude)   #see the graphics window
data(peas)
pairs.panels(peas,lm=TRUE,xlim=c(14,22),ylim=c(14,22))

Run the code above in your browser using DataLab