plotHeatmapCorr: Correlation heatmap

Description Usage Arguments Details Author(s) Examples

Description

Generate a matrix or non-matrix style heatmap of correlation coefficients.

Usage

1
2
3
4
plotHeatmapCorr(data, x, y = NULL, x.name.sub, y.name.sub,
  heat.colours = c("darkorange2", "skyblue4"), show.corr.values = TRUE,
  ylab = y.axis.label, xlab = x.axis.label, print.corr.values = FALSE,
  y.axis.label = NULL, x.axis.label = NULL)

Arguments

data

The dataset to plot.

x

The x axis variables.

y

The y axis variables.

x.name.sub

The substitutions to the x axis names, incase the original variables need to be clarified (eg. 'Wgt' to 'Weight'). Use (probably) best command to use is the gsub command.

y.name.sub

Same as the x.name.sub, but for the y axis variables.

heat.colours

The spectrum of colours for the heat map, as a vector between the lowest (negative) correlation and the highest (positive) correlation.

show.corr.values

Logical; add the correlation values to the heatmap.

print.corr.values

Logical; If true, prints the correlation values.

y.axis.label,ylab
x.axis.label,xlab
corr.text.size

Size of the text that show the correlation values.

Details

This function takes two arguments, the x variables and the y variables, and generates a heatmap from the variables. A correlation matrix is computed from the data, melted (reshape package), and input into ggplot2 to generate a heatmap. The output is the correlations and the plot object.

Author(s)

Luke W. Johnston

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(state)
plotHeatmapCorr(state.x77, c('Income', 'Population'), c('Frost', 'Murder'))

xvars <- c('Income', 'Population', 'Area', 'Frost')
## Replace Area with 'Land Area (km^2)', etc, on the axes using the gsub command
plotHeatmapCorr(state.x77, xvars, print.corr.values = TRUE,
                x.name.sub = xvars %>%
                  gsub('Area', 'Land Area (km^2)', .) %>%
                  gsub('Income', 'Income ($)', .)
                )

lwjohnst86/rstatsToolkit documentation built on May 21, 2019, 9:15 a.m.