User Tools

Site Tools


cs:mix:ordination_artefacts:solution

2D varianta

simul.short.spe <- read.delim ('http://www.davidzeleny.net/anadat-r/data-download/simul.short-spe.txt', row.names = 1)
 
simul.long.spe <- read.delim ('http://www.davidzeleny.net/anadat-r/data-download/simul.long-spe.txt', row.names = 1)
 
simul.table <- simul.short.spe # choose which data to use, if simul.short.spe or simul.long.spe
# simul.table <- simul.long.spe
 
library (vegan)
 
par (mfrow = c (2,2))
 
dca <- decorana (simul.table)
plot (dca$rproj, main = 'DCA')
for (i in seq (1, 70, by = 10)) lines (dca$rproj[i:(i+9), 1:2])
for (j in 0:9) lines (dca$rproj[seq (1, 70, by = 10)+j, 1:2])
 
nmds <- metaMDS (vegdist (simul.table))
plot (nmds$points, main = 'NMDS')
for (i in seq (1, 70, by = 10)) lines (nmds$points[i:(i+9),])
for (j in 0:9) lines (nmds$points[seq (1, 70, by = 10)+j,])
 
pca <- rda (simul.table)
plot (pca$CA$u[, 1:2], main = 'PCA')
for (i in seq (1, 70, by = 10)) lines (pca$CA$u[i:(i+9),1:2])
for (j in 0:9) lines (pca$CA$u[seq (1, 70, by = 10)+j,1:2])
 
ca <- cca (simul.table)
plot (ca$CA$u[, 1:2], main = 'CA')
for (i in seq (1, 70, by = 10)) lines (ca$CA$u[i:(i+9),1:2])
for (j in 0:9) lines (ca$CA$u[seq (1, 70, by = 10)+j,1:2])

3D varianta

simul.short.spe <- read.delim ('http://www.davidzeleny.net/anadat-r/data-download/simul.short-spe.txt', row.names = 1)
 
simul.long.spe <- read.delim ('http://www.davidzeleny.net/anadat-r/data-download/simul.long-spe.txt', row.names = 1)
 
simul.table <- simul.short.spe # choose which data to use, if simul.short.spe or simul.long.spe
# simul.table <- simul.long.spe
 
library (vegan)
 
dca <- decorana (simul.table)
nmds <- metaMDS (vegdist (simul.table), trymax = 0, k = 3)
pca <- rda (simul.table)
ca <- cca (simul.table)
 
 
ordirgl (dca, col = 'black')
rgl.bg (color = 'white')
sites <- scores (dca, choices = c (1:3))
for (i in seq (1, 60)[seq (-10, -60, by = -10)]) rgl.quads (sites[c(i, i+1, i+11, i+10),1], sites[c(i, i+1, i+11, i+10),2], sites[c(i, i+1, i+11, i+10),3], col = 'blue', alpha = 0.5)
 
ordirgl (nmds)
rgl.bg (color = 'white')
sites <- scores (nmds, choices = c(1:3))
for (i in seq (1, 60)[seq (-10, -60, by = -10)]) rgl.quads (sites[c(i, i+1, i+11, i+10),1], sites[c(i, i+1, i+11, i+10),2], sites[c(i, i+1, i+11, i+10),3], col = 'blue', alpha = 0.5)
 
ordirgl (pca)
rgl.bg (color = 'white')
sites <- scores (pca, choices = c(1:3))$sites
for (i in seq (1, 60)[seq (-10, -60, by = -10)]) rgl.quads (sites[c(i, i+1, i+11, i+10),1], sites[c(i, i+1, i+11, i+10),2], sites[c(i, i+1, i+11, i+10),3], col = 'blue', alpha = 0.5)
 
ordirgl (ca)
rgl.bg (color = 'white')
sites <- scores (ca, choices = c (1:3))$sites
for (i in seq (1, 60)[seq (-10, -60, by = -10)]) rgl.quads (sites[c(i, i+1, i+11, i+10),1], sites[c(i, i+1, i+11, i+10),2], sites[c(i, i+1, i+11, i+10),3], col = 'blue', alpha = 0.5)
cs/mix/ordination_artefacts/solution.txt · Last modified: 2017/10/11 20:36 (external edit)