Skip to contents

Create a presence/absence object Create a presence/absence (pa) object from a matrix.

Usage

ec_pa(x, threshold = 0, spc_name = NULL, sit_name = NULL)

Arguments

x

a R object to be coerced as a matrix.

threshold

threshold value. Above (strictly) this value, a species is considered present.

spc_name

vector of species names.

sit_name

vector of site names.

Value

An object of class pa which basically is a matrix of 0 (absence) and 1 (presence).

Details

The input x should be a presence absence matrix (sites as rows and species as columns), it could be either a logical one or a numeric one. In the latter case, presence and absence will be determined based on threshold. If there are less names than species (or sites), or no names at all, then names will be automatically added. These names are created using column or row numbers (zero-padded to the number of digits of total the number of column or row), preceded by spc_ for column and sit_ for sites.

Examples

ec_pa(matrix(c(0, 0, 0, 1, 1, 0, 1, 0, 0), 3, 3), spc_name = "Lynx", sit_name = "ON_001")
#>  Less names than sites, names have been generated.
#>  Less names than species, names have been generated.
#> ! No presence data for the following species: 1
#> ! Empty site(s): 3
#>  Presence absence matrix: 3 sites, 3 species, 3 occurrences.
#>        Lynx spc_2 spc_3
#> ON_001    0     1     1
#> sit_2     0     1     0
#> sit_3     0     0     0