name_stages: Add stage names to matrices

View source: R/name_stages.R

name_stagesR Documentation

Add stage names to matrices

Description

Adds user-supplied or automatically-generated stage names to a matrix population model (MPM).

Usage

name_stages(mat, names = NULL, prefix = "stage_", left_pad = TRUE)

Arguments

mat

An MPM, either as a single matrix or list of matrices.

names

A character vector specifying the name of each life stage, in order. If provided, prefix and left_pad arguments are ignored.

prefix

A string to be pre-pended to the stage number when automatically naming stages. Defaults to stage_.

left_pad

Logical, whether to pre-pend 0 to stage names such that all stage numbers have equal length, enabling lexicographic sorting. For example, stage 1 becomes 01 for matrices with 10-99 stages, 001 for matrices with 100-999 stages, and so on. Defaults to TRUE.

Value

The input matrix or matrices with named rows and columns.

Author(s)

William K. Petry <wpetry@ncsu.edu>

See Also

Other transformation: is_leslie_matrix(), leslie_collapse(), mpm_collapse(), mpm_rearrange(), mpm_split(), mpm_standardize(), repro_stages(), standard_stages()

Examples

matU <- rbind(
  c(0.0, 0.0, 0.0),
  c(0.3, 0.1, 0.0),
  c(0.0, 0.5, 0.8)
)
# (semi)automated naming
name_stages(matU)
name_stages(matU, prefix = "s")
# custom stage names
name_stages(matU, names = c("small", "medium", "large"))
# overwrite existing stage names
data(mpm1)
name_stages(mpm1)


Rage documentation built on Sept. 30, 2023, 1:06 a.m.