# Example of constrained ordination using seedlings data from Ohrazeni
# Upload the dataset stored online:
seedlings.spe <- read.delim ('http://www.davidzeleny.net/anadat-r/data-download/seedl-spe.txt', row.names = 1)
seedlings.env <- read.delim ('http://www.davidzeleny.net/anadat-r/data-download/seedl-env.txt', row.names = 1)
library (vegan)
DCA <- decorana (seedlings.spe)
DCA
#seedlings.spe <- log1p (seedlings.spe)
# Calculate redundancy analysis (linear method) with treatment as explanatory variable and bloc as covariable (coded as factor)
RDA <- rda (seedlings.spe ~ treatment + Condition (as.factor (block)), data = seedlings.env)
RDA
set.seed (234) # this sets the random number generator (use this if you want the same results of permutation tests)
anova (RDA)
windows ()
plot (RDA)
set.seed (234)
anova (RDA, by = 'axis')
# How to calculate adjusted R2:
r2 <- RsquareAdj (RDA)
r2$adj.r.squared