## Compare species: number of occurrences
# Compute the number of sites where each species is present
# To sum by columns, the second argument of apply(), MARGIN,
# is set to 2
spe.pres <- apply(spe > 0, 2, sum)
# Sort the results in increasing order
sort(spe.pres)
# Compute percentage frequencies
spe.relf <- 100 * spe.pres/nrow(spe)
# Round the sorted output to 1 digit
round(sort(spe.relf), 1)
# Plot the histograms
par(mfrow = c(1,2))
hist(spe.pres,
main = "Species Occurrences",
right = FALSE,
las = 1,
xlab = "Number of occurrences",
ylab = "Number of species",
breaks = seq(0, 30, by = 5),
col = "bisque"
)
hist(spe.relf,
main = "Species Relative Frequencies",
right = FALSE,
las = 1,
xlab = "Frequency of occurrences (%)",
ylab = "Number of species",
breaks = seq(0, 100, by = 10),
col = "bisque"
)
Hint Examine the use of the apply() function, applied here to the columns of the
data frame spe. Note that the first part of the function call (spe > 0) evaluates
the values in the data frame to TRUE/FALSE, and the number of TRUE cases per
column is counted by summing.
Now that we have seen at how many sites each species is present, we may want to
know how many species are present at each site (species richness, Fig. 2.5):
2.2 Data Exploration
19
Précédent

- 33/444

Suivant