Correlation plot
Description
Plots a correlation matrix of a series of variables.
plot_correlation(
data,
var,
var_label = NULL,
method = "pearson",
plot_type = c("circle", "number"),
scale = 1,
title = NULL,
palette = "IDE1"
)Arguments
data: Data frame containing equally spaced (daily, weekly, monthly) covariate or disease case observations for one or multiple locations.var: Character vector containing at least two, non-duplicated variables indatato include in the correlation matrix.var_label: Optional character vector of the same length asvarcontaining custom names for the variables.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 by 10% while 0.9 decreases it by 10%.title: Optional title of the plot.palette: GHR, RColorBrewer or colorspace palette. Use “-” before the palette name (e.g., “-Reds”) to reverse it.
Returns
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"
)
# Spearman correlation plot of type 'raster' and 'number'
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"
)