View source: R/community_collection.R
SiteBySpeciesMatrix | R Documentation |
Returns a matrix with a column per community and a row per unique node within communities in the collection.
SiteBySpeciesMatrix(collection, abundance=NULL, na.missing=FALSE)
collection |
an object of class |
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 |
na.missing |
if |
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.
A matrix
.
Lawrence Hudson
CommunityCollection
, NPS
,
CollectionCPS
, Biomass
,
Log10Biomass
, matrix
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.