corrplotter: Function to produce correlation panel plots

Description Usage Arguments Details Value Examples

Description

Fairly versatile function to produce paneled correlation plots, where the lower triangle of panels shows the x,y relationship, the diagonal shows a histogram of each column of data, and the upper triangle summarizes the correlation.

Usage

1
2
3
4
corrplotter(dataframe, ids, hist.breaks, hist.col, hist.names, hist.names.cex,
  hist.names.spacing, hist.y, summary.cex, neg.color, mid.color, pos.color,
  pt.col, par.oma, par.tcl, par.mgp, par.lab, left.text, bottom.text,
  left.text.cex, bottom.text.cex, expansion, ...)

Arguments

dataframe

The object you want to pull data from to plot.

ids

Optional vector of column IDs or names you want to plot from dataframe.

hist.breaks

The number of breaks desired in the diagonal histograms. Default is 10.

hist.col

The color of the histograms. Default is black.

hist.names

The titles to be printed above histograms, if desired. Will be left blank if not provided.

hist.names.cex

The size of the hist.names titles. Defaults to 1.

hist.names.spacing

The space of the title below the top of the histogram plot. Default is -2. Increasing this number will move the title closer to the top of the panel.

hist.y

The y-axis label in the diagonal histograms. Defaults to blank, but can be set to, e.g., "Frequency".

summary.cex

The size of the summary stat text in the upper half of the plots. Default is 2.

neg.color

The background color of the panel in the upper half of the plots for correlations with negative coefficients. It is very important that this be formatted as a vector of length four, minimum 0, maximum 1, corresponding to rgb + alpha channel. All other formats will fail. Default is red, with alpha 0.5.

mid.color

The background color of the panel in the upper half of the plots for non-existent correlations. Format the same as neg.color. Default is white.

pos.color

The background color of the panel in the upper half of the plots for correlations with positive coefficients. Format the same as neg.color. Default is blue, with alpha 0.5.

pt.col

The color of the points in scatterplots. Default is black.

par.oma

Used to format the space around the entire plot (the area outside all panels). The format is c(bottom, left, top, right). Default is c(4, 4, 2, 2).

par.tcl

Used to control the length of the tick marks inside the panels. Default is -0.25.

par.mgp

Used to control the distance of the labels from the tick marks inside the panels. Default is c(2, 0.2, 0).

par.lab

Used to control the number of tick marks inside the panels. Format is c(x, y, len). Although len is not implemented in R, it is necessary to pass along. Default is c(5, 5, 7).

left.text

The labels to be printed along each panel on the left margin of the figure. A common thing people will want to do is to reverse the columns plotted along the bottom axis and drop the last one. Example of how to do this, if, for example, you are plotting all the columns of your data frame except the first: c(rev(names(yourDF[,2:dim(yourDF)[2]])),""). You actually don't need to bind the blank in in this example, but it's shown here for completeness.

bottom.text

Like left.text, but for the bottom axis labels.

left.text.cex

The size of the left.text labels. Defaults to 1.

bottom.text.cex

The size of the bottom.text labels. Defaults to 1.

expansion

Controls how much the histogram is shrunk down to facilitate plotting of histogram names. Also controls how zoomed out the scatterplots are, which might be useful for ensuring dots do not interfere with axis labels.

...

Other arguments that can be passed to plot, including cex for the dots in the scatterplot and for the axis labels.

Details

There are a large variety of options that can be customized on this function, but fundamentally it places scatterplots in the lower triangle of the plot, histograms along the diagram, and a summary of the correlation in the upper triangle.

Value

A paneled correlation plot.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
exData <- data.frame(
col1=jitter(sort(rnorm(n=200, mean=0, sd=1), decreasing=TRUE), amount=1),
col2=jitter(sort(rnorm(n=200, mean=10, sd=1)), amount=4),
col3=jitter(sort(rnorm(n=200, mean=-3, sd=1)), amount=3))

corrplotter(dataframe=exData, hist.breaks=20, hist.col="purple",
hist.names=c("one","two","three"), left.text=c("units1", "units2", ""),
bottom.text=c("other_units1", "other_units2", "other_units3"),
summary.cex=2, neg.color=c(1,0,0,1), mid.color=c(1,1,0,1), pos.color=c(0,1,0,1),
expansion=0.5, cex=0.5, pt.col="gray")

eliotmiller/corrplotter documentation built on May 16, 2019, 3:02 a.m.