Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

corVar

Print Correlated Variables


Description

Utility that prints the name of correlated variables and the relative correlation coefficient value.

Usage

corVar(
  bg,
  method = "spearman",
  cor_th = NULL,
  order = TRUE,
  remove_diagonal = TRUE
)

Arguments

bg

SWD object with the locations used to compute the correlation between environmental variables.

method

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

cor_th

numeric. If provided it prints only the variables whose correlation coefficient is higher or lower than the given threshold, default is NULL.

order

logical, if TRUE the variable are ordered from the most to the less highly correlated, default is TRUE.

remove_diagonal

logical, if TRUE the values in the diagonal are, removed, default is TRUE.

Value

The name of the correlated variables.

Author(s)

Sergio Vignali

Examples

# 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")

# Get the correlation among all the environmental variables
corVar(bg, method = "spearman")

# Get the environmental variables that have a correlation greater or equal to
# the given threshold
corVar(bg, method = "pearson", cor_th = 0.8)

SDMtune

Species Distribution Model Selection

v1.1.4
GPL-3
Authors
Sergio Vignali [aut, cre] (<https://orcid.org/0000-0002-3390-5442>), Arnaud Barras [aut] (<https://orcid.org/0000-0003-0850-6965>), Veronika Braunisch [aut] (<https://orcid.org/0000-0001-7035-4662>), Conservation Biology - University of Bern [fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.