require(vegan)
data(mite)
data(mite.xy)
comm_matrix <- mite
# Spatially-explicit curves can be obtained as follows
spatialdist <- dist(mite.xy) # to calculate the geographic
# distance between plots, i.e. the Euclidean distance
# between the coordinates of the plots)
betas <- directionalSAC(comm_matrix, spatialdist) # to calculate directional
# and non directional beta diversity
plot(1:70, betas$N_Exact, xlab="M", ylab="Species richness", ylim=range(c(betas$N_Exact,
betas$N_SCR, betas$Alpha, mean(apply(comm_matrix, 1, function(x) length(x[x>0]))))))
points(1:70,rep( mean(apply(comm_matrix, 1, function(x) length(x[x>0]))), 70), pch=2)
points(1:70, betas$N_SCR, pch=3)
points(1:70, betas$Alpha_dir, pch=4)
legend("right", legend=c("Non-directional SAC",
"Non-directional alpha diversity", "Directional SAC",
"Directional alpha diversity"), pch=1:4)
# M is the number of plots
plot(1:70, betas$Beta_M, xlab="M", ylab="Beta diversity",
ylim=range(c(betas$Beta_M_dir, betas$Beta_M)))
points(1:70, betas$Beta_M_dir, pch=2)
legend("right", legend=c("Non-directional beta", "Directional beta"), pch=1:2)
plot(2:70, betas$Beta_N[2:70], xlab="M", ylab="Normalized beta diversity",
ylim=range(c(betas$Beta_N_dir[2:70], betas$Beta_N[2:70])))
points(2:70, betas$Beta_N_dir[2:70], pch=2)
legend("right", legend=c("Non-directional beta", "Directional beta"), pch=1:2)
plot(2:70, betas$Beta_Autocor[2:70], xlab="M",
ylab="Normalized measure of autocorrelation")
Run the code above in your browser using DataLab