User Tools

Site Tools

You are not allowed to perform this action

pairs (with panel functions)

Author: Francois Gillet

Draws advanced pairplot (see example below). Based on the base function pairs, with original code written by R-code members and panel functions added by Francois Gillet.

To define the function, source the panelutils.r file from Numerical Ecology with R book:

source ('')

Example of use (using environmental data from the dataset Vegetation of Carpathian wetlands, after removing the 15th variable which is slope and not water chemistry):

source ('')
chem <- read.delim ('', row.names = 1) # reads the ''chem'' dataset
pairs(chem[,-15], lower.panel=panel.smooth, upper.panel=panel.cor, diag.panel=panel.hist)

Panels in the upper triangle = correlation coefficients with results of significance testing (displayed by the number of stars), red for positive and blue for negative relationships, values in bold are significant at least at P < 0.05). Panels on diagonal = histograms of distribution. Panels on lower triangle = scatterplot with loess smoother curve.

Most of the variables need to be log-transformed (they have heavily right-skewed distribution); after the log-transformation, the result looks like this:

chem_t <- chem
chem_t[, 1:12] <- log (chem[, 1:12])
pairs(chem_t[,-15], lower.panel=panel.smooth, upper.panel=panel.cor, diag.panel=panel.hist)

Note that the package car contains the function scatterplotMatrix, which is doing something similar (and perhaps could be also further customized).

en/customized_functions/pairs2.txt · Last modified: 2019/02/22 18:08 by David Zelený