The function cleans a species matrix by removing species without occurrence (frequency = 0) and samples without any species (species number = 0) in one step.

It will also subset the corresponding observations of environmental data (samples in rows) or species trait data (species in rows), if passed to the function.

clean_matrix(matrix, env = NULL, traits = NULL)

Arguments

matrix

Community data, a matrix-like object with samples in rows and species in columns. Missing values (NA) or empty character cell values will be transformed to 0.

env

Optionally, a data frame of environmental variables, with samples in rows and variables in columns

traits

Optionally, a data frame of species traits, with species in rows and trait variables in columns

Value

If only a species matrix is provided, the return will be a cleaned species matrix. If environmental and/or trait data are also provided, the result will be a list of the cleaned and subsetted matrices/data frames.

Author

Friedemann von Lampe (fvonlampe@uni-goettingen.de)

Examples

# Clean species matrix
schedenveg.clean <- clean_matrix(schedenveg)
#> [1] "Removed 0 species without occurence and 0 samples without any species"

# Clean species matrix and subset environmental data
scheden.clean <- clean_matrix(schedenveg, schedenenv)
#> [1] "Removed 0 species without occurence and 0 samples without any species"
schedenveg.clean <- scheden.clean$matrix
schedenenv.clean <- scheden.clean$env