plotCorrmatrix {growthPheno} | R Documentation |
Calculates and plots correlation matrices for a set of responses
Description
Having calculated the correlations a heat map indicating the magnitude of the
correlations is produced using ggplot
. In this heat map, the darker the red in
a cell then the closer the correlation is to -1, while the deeper the blue in the cell,
then the closer the correlation is to 1. Matrix plots of all pairwise
combinations of the variables can be produced that includes the values of the
the correlation coefficients. If pairs.sets
is set, a matrix
plot, along with the values of the correlation coefficients, is produced for
each of the pair.sets
. That is, the argument pairs.sets
can be used to
restrict the pairs in a matrix plot to those combinations within each set.
Usage
plotCorrmatrix(data, responses, which.plots = c("heatmap","matrixplots"),
title = NULL, labels = NULL, labelSize = 4, pairs.sets = NULL,
show.sig = TRUE, axis.text.size = 20, ggplotFuncs = NULL,
printPlot = TRUE, ...)
Arguments
data |
A |
responses |
A |
which.plots |
A |
title |
Title for the plots. |
labels |
A |
labelSize |
A |
pairs.sets |
A |
show.sig |
A |
axis.text.size |
A |
ggplotFuncs |
A |
printPlot |
A |
... |
allows passing of arguments to other functions; not used at present. |
Details
The correlations and their p-values are producced using rcorr
from the Hmisc
package. The heatmap
is produced using
ggplot
and the matrixplots are produced using GGally
.
Value
A list
object that has components heatmap
and matrixplots
. The component heatmap
will contain the heatmap plot, if produced, as an object of class "ggplot
", which can be plotted using print
; otherwise NULL
is returned.
Similarly, if not NULL
, the component matrixplots
will contain a list with one or more components, depending on the setting of pair.sets
, each of which is a scatterplot matrix stored as an object of class "ggmatrix
".
Author(s)
Chris Brien
See Also
rcorr
, GGally
, ggplot
.
Examples
data(exampleData)
longi.dat <- prepImageData(data=raw.dat, smarthouse.lev=1)
longi.dat <- within(longi.dat,
{
Max.Height <- pmax(Max.Dist.Above.Horizon.Line.SV1,
Max.Dist.Above.Horizon.Line.SV2)
Density <- PSA/Max.Height
PSA.SV = (PSA.SV1 + PSA.SV2) / 2
Image.Biomass = PSA.SV * (PSA.TV^0.5)
Centre.Mass <- (Center.Of.Mass.Y.SV1 + Center.Of.Mass.Y.SV2) / 2
Compactness.SV = (Compactness.SV1 + Compactness.SV2) / 2
})
responses <- c("PSA","PSA.SV","PSA.TV", "Image.Biomass", "Max.Height","Centre.Mass",
"Density", "Compactness.TV", "Compactness.SV")
plotCorrmatrix(longi.dat, responses, pairs.sets=list(c(1:4),c(5:7)))