humboldt.plot.contrib: Plot PCA contribution to environmental space

View source: R/humboldt70.R

humboldt.plot.contribR Documentation

Plot PCA contribution to environmental space

Description

Plot PCA contribution to environmental space

Usage

humboldt.plot.contrib(
  contrib = pca.cal$co,
  pcx = 1,
  pcy = 2,
  eigen = pca.cal$eig
)

Arguments

contrib

The contribution of the environmental variables included in PCA

pcx

An integer that identifies one (of two) principal components used to perform niche quantification and quantitative tests on. Default=1. Both defaults result in the 1st and 2nd PCs being compared.

pcy

An integer that identifies the second (of two) principal components used to perform niche quantification and quantitative tests on. Default=2. Both defaults result in the 1st and 2nd PCs being compared.

eigen

Eigen values output from ordinations

Value

Plots the contribution of the environmental variables to the analysis. Typically these are eigen vectors and eigen values in ordinations.

See Also

humboldt.sample.spp,humboldt.g2e, humboldt.equivalence.stat, humboldt.background.stat, humboldt.niche.similarity, humboldt.plot.niche,humboldt.doitall which use or depend on outputs of this function

Examples

library(humboldt)

##load environmental variables for all sites of the study area 1 (env1). Column names should be x,y,X1,X2,...,Xn)
env1<-read.delim("env1.txt",h=T,sep="\t")

## load environmental variables for all sites of the study area 2 (env2). Column names should be x,y,X1,X2,...,Xn)
env2<-read.delim("env2.txt",h=T,sep="\t") 

## remove NAs and make sure all variables are imported as numbers
env1<-humboldt.scrub.env(env1)
env2<-humboldt.scrub.env(env2)

##load occurrence sites for the species at study area 1 (env1). Column names should be 'sp', 'x','y'
occ.sp1<-na.exclude(read.delim("sp1.txt",h=T,sep="\t"))

##load occurrence sites for the species at study area 2 (env2). Column names should be 'sp', 'x','y' 
occ.sp2<-na.exclude(read.delim("sp2.txt",h=T,sep="\t"))

##convert geographic space to espace
zz<-humboldt.g2e(env1=env1, env2=env2, sp1=occ.sp1, sp2=occ.sp2, reduce.env = 2, reductype = "PCA", non.analogous.environments = "NO", env.trim= T, e.var=c(3:21),  col.env = e.var, trim.buffer.sp1 = 200, trim.buffer.sp2 = 200, rarefy.dist = 50, rarefy.units="km", env.reso=0.41666669, kern.smooth = 1, R = 100, run.silent = F)

## plot pca contributions
humboldt.plot.contrib(zz$pca.cal$co,zz$pca.cal$eig)

jasonleebrown/humboldt documentation built on Jan. 4, 2024, 7:46 a.m.