humboldt.plot.density | R Documentation |
Plot equivalence or background statistic: simulation density curve
humboldt.plot.density(x, type = "D", title = "Background")
x |
Output from niche equivalence statistic (humboldt.equivalence.stat). |
type |
Values "D" or "I", which correspond to niche similarity using Schoener's D and Hellinger's I measurements |
title |
Title of plot |
Plots the results from the Background statistic (humboldt.background.stat).
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
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)
##perform background statistics
bg.sp1tosp2<-humboldt.background.stat(g2e=zz, rep = 100, sim.dir = 1, env.reso, kern.smooth = 1, correct.env = F, R = 100, run.silent.bak = F)
bg.sp2tosp1<-humboldt.background.stat(g2e=zz, rep = 100, sim.dir = 2, env.reso, kern.smooth = 1, correct.env = F, R = 100, run.silent.bak = F)
##plot background statistics
humboldt.plot.density(bg.sp1tosp2,"D","Background 1->2")
humboldt.plot.density(bg.sp2tosp1,"D","Background 2->1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.