# Load the function BCI, which contains the Barro Colorado State Forrest data, and will produce a matix
# of species within the whole dataset in 2010.
library(BCI)
bci_2010 <- bci_2010
# No that we have the BCI 2010 data, we can create populations based on our data, which we will use to
# explore differnet diversity measures, and test the functions which we create to measure community
# species diversity.
# create a vector of the total counts of of trees of different species in the forest plot
tree.pop <- rowSums(bci_2010)
# we can now extract some information from the full species count:
# names of all the species within the dataset
species.names <- names(tree.pop)
# The number of species present in the dataset
num.sp <- length(tree.pop)
# The total number of individual trees within the dataset
num.trees <- sum(tree.pop)
# The mean number of trees of each speceis
mean.trees <- mean(tree.pop)
# the next two lines sample a single random quadrat and sums up 10 random quadrats, and stores the results,
# respectively
quadrat.pop <- rowSums(sample_by_subcommunities(bci_2010, 1))
quadrat10.pop <- rowSums(sample_by_subcommunities(bci_2010, 10))
# One pop has a population with 222718 individuals od one species and no individuals of any other species
one.pop <- c(num.trees, rep(0, num.sp -1))
# Uneven.pop: contains 111728 individuals of one species and 369 individuals of every other species
uneven.pop <- c(num.trees / 2, rep(0, num.sp - 1)) +
rep(mean.trees / 2, num.sp)
# Mixed.pop: population with a highly variable number of individuals of each species
mixed.pop <- (1:num.sp) / sum(1:num.sp) * num.trees
# Even.pop: population with 739 individuals of every species
even.pop <- rep(mean.trees, num.sp)
# rand.pop: contains a random number of individuals of each species (with the same propability for each
# species) drawn from the actual data once
rand.pop <- as.vector(rmultinom(1, num.trees,
rep(1 / num.sp, num.sp)))
# rand50.pop: contains a random number of individuals of each species (with the same propability for each
# species) drawn from the actual data 50 times
rand50.pop <- as.vector(rmultinom(1, round(num.trees / 50),
rep(1 / num.sp, num.sp)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.