site_by_species: Create site x species matrix

View source: R/site_by_species.R

site_by_speciesR Documentation

Create site x species matrix

Description

Takes in a neighborhoods object output by the neighborhoods function and returns a site x species matrix where each site is a neighborhood. The user can specify whether the values in the matrix represent abundance or presence/absence.

Usage

site_by_species(neighbors, id_column, abundance = F)

Arguments

neighbors

A neighborhoods object output by the neighborhoods function.

id_column

Name of column in neighbors containing site names as a string.

abundance

Boolean specifying whether an abundance or presence/absence site x species matrix is desired (default is presence/absence).

Value

A site x species matrix where each row represents a distinct site or neighborhood and each column represents a tree species. Row names are the site names. If abundance = F presence is indicated by 1 and absence by 0. If abundance = T values represent the number of trees of that species in the neighborhood (excluding the focal if neighborhoods are centered on a focal tree).

Examples

# Create a neighborhoods object
nbhds <- neighborhoods(mapping, stands = "AB08", radius = 10)

# Create abundance-weighted site-by-species matrix
s_by_sp <- site_by_species(nbhds, id_column = "tree_id", abundance = T)

sgraham9319/ForestPlotR documentation built on April 15, 2022, 4:01 p.m.