Ellenberg indicator values - the way how to compute it using R software (www.r-project.org). The example data and code of function are below:
spec = read.delim('clipboard', row.names=1, h=T) # load species data - first sheet of data halophytes.xlsx
ell = read.delim('clipboard', h=T) # load Ellenberg indicator values - second sheet of the file
Example of calculation:
B <-eiv(species=spec, EIVS=ell, type='b') # it calculates arithmetic means
W <-eiv(species=spec, EIVS=ell, type='w') # it calculates community weighted means
# This function computes community-weighted means or arithmetic means of Ellenberg indicators values (EIV)
# Species data and EIV for species are needed. The function requires all Ellenberg indicator values.
# If you do not have particular EIV for species then NA must be written in EIV dataset or edit function and remove some of
# them
# In EIV dataset original values of EIV numbers and x should be written
eiv <- function (species, EIVS, type=c('w', 'b'))
{
EIVS[EIVS == "x"] <- NA # replace x with NA
nrow0 <- function(x) dim(x)[1]# calculates number of rows (species)
lb <-nrow0(species)
rows.num=c(1: lb) # define number of rows in data.frame
Ell = as.data.frame(rows.num)
L =as.numeric(as.character(EIVS$L[match(names(species), EIVS$species)]))
T =as.numeric(as.character(EIVS$T[match(names(species), EIVS$species)]))
K =as.numeric(as.character(EIVS$K[match(names(species), EIVS$species)]))
F =as.numeric(as.character(EIVS$F[match(names(species), EIVS$species)]))
R =as.numeric(as.character(EIVS$R[match(names(species), EIVS$species)]))
N =as.numeric(as.character(EIVS$N[match(names(species), EIVS$species)]))
S =as.numeric(as.character(EIVS$S[match(names(species), EIVS$species)]))
type <- match.arg(type)
switch(type, w = {
Ell$L <- apply(species, 1, function(x) weighted.mean(L, x, na.rm=TRUE))
Ell$T <- apply(species, 1, function(x) weighted.mean(T, x, na.rm=TRUE))
Ell$K <- apply(species, 1, function(x) weighted.mean(K, x, na.rm=TRUE))
Ell$F <- apply(species, 1, function(x) weighted.mean(F, x, na.rm=TRUE))
Ell$R <- apply(species, 1, function(x) weighted.mean(R, x, na.rm=TRUE))
Ell$N <- apply(species, 1, function(x) weighted.mean(N, x, na.rm=TRUE))
Ell$S <- apply(species, 1, function(x) weighted.mean(S, x, na.rm=TRUE))
Ell
} , b = {spec1 <-species > 0
Ellm = as.data.frame(rows.num)
Ellm$mL <- apply(spec1, 1, function(x) weighted.mean(L, x, na.rm=TRUE))
Ellm$mT <- apply(spec1, 1, function(x) weighted.mean(T, x, na.rm=TRUE))
Ellm$mK <- apply(spec1, 1, function(x) weighted.mean(K, x, na.rm=TRUE))
Ellm$mF <- apply(spec1, 1, function(x) weighted.mean(F, x, na.rm=TRUE))
Ellm$mR <- apply(spec1, 1, function(x) weighted.mean(R, x, na.rm=TRUE))
Ellm$mN <- apply(spec1, 1, function(x) weighted.mean(N, x, na.rm=TRUE))
Ellm$mS <- apply(spec1, 1, function(x) weighted.mean(S, x, na.rm=TRUE))
Ellm})
}