plotCor: Plot Correlation

Description Usage Arguments Value Author(s) Examples

View source: R/plotCor.R

Description

Plot a correlation matrix heat map with the value of the correlation coefficients according with the given method. If cor_th is passed then it prints only the coefficients that are higher or lower than the given threshold.

Usage

1
plotCor(bg, method = "spearman", cor_th = NULL)

Arguments

bg

SWD object used to compute the correlation matrix.

method

character. The method used to compute the correlation matrix, default is "spearman".

cor_th

numeric. If provided it prints only the coefficients that are higher or lower than the given threshold, default is NULL.

Value

A ggplot object.

Author(s)

Sergio Vignali

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Acquire environmental variables
files <- list.files(path = file.path(system.file(package = "dismo"), "ex"),
                    pattern = "grd", full.names = TRUE)
predictors <- raster::stack(files)

# Prepare background locations
bg_coords <- dismo::randomPoints(predictors, 10000)

# Create SWD object
bg <- prepareSWD(species = "Virtual species", a = bg_coords,
                 env = predictors, categorical = "biome")

# Plot heat map
plotCor(bg, method = "spearman")

# Plot heat map showing only values higher than given threshold
plotCor(bg, method = "spearman", cor_th = 0.8)

SDMtune documentation built on July 17, 2021, 9:06 a.m.