com_matrix.Rd
This function is used to create a list of i x j matrices where i is the number of geographical groups and j is the total number of species. The matrix is filled in with the presence (1) and absence (0) of each species in the data for a particular taxonomic group. The function requires the package 'reshape'
com_matrix(
data,
species,
geo_group,
taxa_group,
status,
stat_levels = unique(data[, status]),
total = TRUE
)
A data frame that holds the species occurrence data with at least 4 columns of factors that holds the geographic groups, taxonomic groups, species statuses, and species binomial names.
A character equal to the column name in which the species binomial names are stored
A character equal to the column name in which the geographic groups are stored (e.g. bank names)
A character or vector equal to the column name(s) in which the names of the taxonomic groups are stored (e.g. genus and/or family names)
A character equal to the column name in which the species' statuses are stored
A character or vector equal to the levels of the interest of the species' status column. The default is to use all of the levels in the species' status column of the data.
Logical, If TRUE
then the total community matrix for all species across all taxonomic groups is
included in the returned list. If FLASE
then this complete community matrix is omitted.
A list of length k where k is the number of taxonomic groups and statuses given to the function.
if (FALSE) {
library(here)
library(reshape)
herp <- read.csv(file.path(here(), 'data_raw', 'IBT_Herp_Records_final.csv'), header=TRUE)
coms <- com_matrix(data = herp,
species = "binomial",
geo_group = "bank",
taxa_group = c("genus","taxon"),
status = "bnk_status",
stat_levels = c('N', "E"),
total = FALSE)
}