corrVars: Produce a correlation matrix of all potential input variables

Description Usage Arguments Value Examples

View source: R/FunctionCorrVars.R

Description

Produce a correlation matrix of all potential input variables

Usage

1
2
corrVars(vars, na.rm = T, method = "color", order = "hclust",
  title = "Layer Correlation Matrix")

Arguments

vars

A raster stack of potential input variables

na.rm

'logical' Should cells with at least one NA be ignored?

order

Ordering method for the correlation matrix plot. See '?corrplot::corrplot' for more details

title

Title for the correlation matrix plot

Value

A matrix of correlation coefficients between layers, and a correlation matrix plot of these coefficients

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#get UK extent
UK <- ggplot2::map_data(map = "world", region = "UK")
max.lat <- ceiling(max(UK$lat))
min.lat <- floor(min(UK$lat))
max.lon <- ceiling(max(UK$long))
min.lon <- floor(min(UK$long))
extent <- raster::extent(x = c(min.lon, max.lon, min.lat, max.lat))

#get variables data
bio<-raster::getData('worldclim',var='bio',res=5,lon=-2,lat=40)

#crop to uk
bio<-raster::crop(bio,extent)

#produce correlation matrix
corr <- corrVars(bio)

#END

jncc/sdms documentation built on Aug. 13, 2021, 4:21 a.m.