fuzzySim (version 2.0)

splist2presabs: Convert a species list to a presence-absence table

Description

This function takes a locality+species dataset in long (stacked) format, i.e., a matrix or data frame containing localities in one column and their recorded species in another column, and converts them to a presence-absence table (wide format) suitable for mapping and for computing distributional similarities (see e.g. simMat). Try out the Examples below for an illustration).

Usage

splist2presabs(data, sites.col, sp.col, keep.n = FALSE)

Arguments

data

a matrix or data frame with localities in one column and species in another column. Type data(rotifers); head(rotifers) for an example.

sites.col

the name or index number of the column containing the localities in data.

sp.col

the name or index number of the column containing the species names or codes in data.

keep.n

logical value indicating whether to get in the resulting table the number of times each species appears in each locality; if FALSE (the default), only presence (1) or absence (0) is recorded.

Value

A data frame containing the localities in the first column and then one column per species indicating their presence (or their number of records if keep.n = TRUE) and absence. Type data(rotif.env); head(rotif.env[,18:47]) for an example.

See Also

table

Examples

Run this code
# NOT RUN {
data(rotifers)

head(rotifers)

rotifers.presabs <- splist2presabs(rotifers, sites.col = "TDWG4",
sp.col = "species", keep.n = FALSE)

head(rotifers.presabs)
# }

Run the code above in your browser using DataLab