Learn R Programming

mefa (version 1.0-4)

marmat: Computes Marginal Sums of Presence Absence or Abundance Matrices

Description

This is a utility function to calculate statistics on data matrices in objects of class 'xcount' and 'mefa'.

Usage

marmat(x, which = c("samples", "species"), method = c("abund", "occur"), group = NULL)

Arguments

x
a matrix containing data.
method
sets method to use, "abund" refers to abundance data (use data in x as is), "occur" (occurence) refers to column/row sums in a presence/absence (binary) matrix.
which
"samples" indicates rows (default), "species" indicates columns, on which the function will be applied over.
group
NULL (default) or a vector with length sames as the number of rows (for which="samples"), or columns (for which="samples"). I NULL it takes the value c(1:nrow(x)) or c(1:nc

Value

  • A result is a vector.

Details

This function can be used on eg. data tables of count or abundance matrices to calculate number of individuals (or eg. total biomass in case of measurements, method="abund") or species richness (method="occur") within samples (which="samples") or groups of samples (which="samples", group differs from the default), or abundance (method="abund") or number of occurences (method="occur") of species (which="species") or species groups (which="species", group differs from the default).

Examples

Run this code
x <- matrix(data = rpois(8*4, 1), nrow = 8, ncol = 4)
rownames(x) <- letters[1:8]
colnames(x) <- LETTERS[1:4]

marmat(x, "samples", "abund")
marmat(x, "samples", "abund", group=c(1,1,2,2,3,3,4,4))
marmat(x, "samples", "occur")
marmat(x, "samples", "occur", group=c(1,1,2,2,3,3,4,4))

marmat(x, "species", "abund")
marmat(x, "species", "abund", group=c(1,1,2,2))
marmat(x, "species", "occur")
marmat(x, "species", "occur", group=c(1,1,2,2))

Run the code above in your browser using DataLab