mx_dropzero: Drop zero-sum rows or columns

Description Usage Arguments Details Value Examples

Description

Drop zero-sum rows or columns from a species abundance matrix, often needed before calculating dissimilarities.

Usage

1
mx_dropzero(x, method = "col", silent = TRUE, ...)

Arguments

x

array of species data, where rows = SUs and cols = species

method

either one of 'col' or 'row'

silent

logical, do not report number of rows or columns dropped?

...

further arguments passed to other methods

Details

Often useful before calculating certain dissimilarity measures.

Value

Modified dataframe or matrix, with fewer rows or columns than the original.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# species abundance data
set.seed(1917)
spe <- data.frame(matrix(rnorm(30, 10, 50), 10, 3))
spe[spe < 0] <- 0
colnames(spe) <- c('Acer rubrum','Acer saccharum','Acer negundo')
spe
mx_dropzero(spe) # returns unchanged abundance matrix or data.frame
spe[,2] <- 0
spe[4,] <- 0
mx_dropzero(spe, 'col') # second column removed
mx_dropzero(spe, 'row') # fourth row removed

phytomosaic/ecole documentation built on May 6, 2019, 3:45 p.m.