SiteBySpeciesMatrix {cheddar} | R Documentation

## Community collection site by species matrix

### Description

Returns a matrix with a column per community and a row per unique node within communities in the collection.

### Usage

    SiteBySpeciesMatrix(collection, abundance=NULL, na.missing=FALSE)

### Arguments

`collection` | an object of class `CommunityCollection`.
`abundance` | the name of a node property that provides abundance values. This can be the name of a first-class propery or the name of a function. The name must meet the criteria of the `properties` parameter of `NPS`.
`na.missing` | if `TRUE` nodes that are absent from the community will be represented by `NA`; if `FALSE`, these nodes are represented by 0.

### Details

If `abundance` is `NULL`, the returned `matrix` indicates presence (1) or absence (0 or `NA` - see `na.missing`) of nodes. If `abundance` is given, values are the abundances of nodes, or 0 or `NA` where nodes are absent.

### Value

A `matrix`.

### Author(s)

Lawrence Hudson

### See Also

`CommunityCollection`, `NPS`, `CollectionCPS`, `Biomass`, `Log10Biomass`, `matrix`

### Examples

    data(pHWebs)

    # If abundance is NULL, you get a presence/absence matrix:
    SiteBySpeciesMatrix(pHWebs)

    # Numerical abundance
    SiteBySpeciesMatrix(pHWebs, 'N')

    # Biomass abundance
    SiteBySpeciesMatrix(pHWebs, 'Biomass')

    # Log10 biomass abundance
    SiteBySpeciesMatrix(pHWebs, 'Log10Biomass')

    # Example showing how to model biomass in term of pH using vegan's rda function
    m <- SiteBySpeciesMatrix(pHWebs, 'Biomass')

    # Some nodes (e.g. CPOM) do not have a biomass. The rows in m for these nodes
    # will contain all NA. Rows containing all NA will upset vegan's rda function
    # so these rows must be removed.
    m <- m[apply(m, 1, function(row) all(!is.na(row))),]

    # Tranpose to get row per site - the format required by vegan's rda function
    m <- t(m)

    # Matrix (with a row per site) of variables on the right hand side of the
    # model equation
    variables <- CollectionCPS(pHWebs)

    ## Not run: library(vegan)
    ## Not run: res <- rda(m~pH,variables)

[Package cheddar version 0.1-633 Index]