clean_matrix: Clean species matrix

View source: R/clean_matrix.R

clean_matrixR Documentation

Clean species matrix

Description

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.

Usage

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) 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(s)

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

Examples

# Clean species matrix
schedenveg.clean <- clean_matrix(schedenveg)

# Clean species matrix and subset environmental data
scheden.clean <- clean_matrix(schedenveg, schedenenv)
schedenveg.clean <- scheden.clean$matrix
schedenenv.clean <- scheden.clean$env


fgoral/goeveg documentation built on Feb. 27, 2024, 6:32 a.m.