PlotPairwiseCorrelations | R Documentation |
Takes a matrix or dataframe and calculates the pairwise correlations between all columns, and plots these as a ggplot tilemap. Optionally, the pairwise correlations can be returned as a tidy tibble.
PlotPairwiseCorrelations(
M,
axis.label = NULL,
return.corr.tibble = FALSE,
plotit = TRUE
)
M |
a matrix or dataframe for which the pairwise corrlelations between the columns are desired. |
axis.label |
charcter string with an optional label for the x and y
figure axes; defaults to |
return.corr.tibble |
logical; return the correlations as a tidy tibble?
Defaults to |
plotit |
logical; plot the correlations? Defaults to |
Ideas for code taken from here: http://www.sthda.com/english/wiki/ggplot2-quick-correlation-matrix-heatmap-r-software-and-data-visualization
Per default, a ggplot2 object; optionally, a list with two elements: the ggplot2 object and the correlations as a tibble.
Andrew Dolman
## Not run:
if(interactive()) {
M <- matrix(rnorm(12 * 100), ncol = 12)
PlotPairwiseCorrelations(M, axis.label = "Month",
return.corr.tibble = TRUE)
# Add names to columns
colnames(M) <- letters[1:12]
PlotPairwiseCorrelations(M, axis.label = "Cat",
return.corr.tibble = TRUE)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.