plot_correlation {GHRexplore} | R Documentation |
Correlation plot
Description
Plots a correlation matrix of a series of variables.
Usage
plot_correlation(
data,
var,
var_label = NULL,
method = "pearson",
plot_type = c("circle", "number"),
scale = 1,
title = NULL,
palette = "IDE1",
print = FALSE
)
Arguments
data |
Data frame containing equally spaced (daily, weekly, monthly) covariate or disease case observations for one or multiple locations. |
var |
Character vector containing variables in |
var_label |
Optional character vector of the same length as |
method |
Correlation computation method. Options include "pearson" (default), "spearman" or "kendall". |
plot_type |
Character vector of length 2 indicating the type of plot to use in the lower triangular and diagonal (1st element) and the upper triangular (2nd element). Options include "circle", "number" and "raster". |
scale |
Circle and number size multiplier, e.g. 1.1 increases the size a 10% while 0.9 decreases it a 10%. |
title |
Optional title of the plot. |
palette |
GHR, RColorBrewer or colorspace palette. Use "-" before the palette name (e.g., "-Reds") to reverse it. |
print |
Logical. If TRUE, print the correlation matrix. |
Value
A plot of the correlation matrix.
Examples
# Load data
data("dengue_MS")
# Pearson correlation plot
plot_correlation(dengue_MS,
method = "pearson",
var = c("dengue_cases","pop_density",
"tmax", "tmin", "pdsi", "urban",
"water_network", "water_shortage"),
var_label = c("dengue cases","pop. density",
"max temp", "min temp", "drought index", "urbanization",
"water network", "water shortage"),
title = "Correlation matrix")
# Print spearman correlation plot of type 'raster' and 'number'
# with another palette
plot_correlation(dengue_MS,
method = "spearman",
var = c("dengue_cases","pop_density",
"tmax", "tmin", "pdsi", "urban",
"water_network", "water_shortage"),
var_label = c("dengue cases","pop. density",
"max temp", "min temp", "drought index", "urbanization",
"water network", "water shortage"),
plot_type = c("raster", "number"),
palette = "-Blue-Red 3")