repro_stages: Identify which stages in a matrix population model are...

View source: R/repro_stages.R

repro_stagesR Documentation

Identify which stages in a matrix population model are reproductive

Description

Takes a reproductive matrix and returns a vector of logical values (TRUE/FALSE) indicating which stages are reproductive (i.e., exhibit any positive values for reproduction). This function is a preparatory step to collapsing the matrix model into a standardized set of stage classes using the function mpm_standardize.

Usage

repro_stages(matR, na_handling = "return.true")

Arguments

matR

The reproductive component of a matrix population model (i.e., a square projection matrix reflecting transitions due to reproduction; either sexual (e.g., matF), clonal (e.g., matC), or both).

na_handling

One of "return.na", "return.true", or "return.false". Determines how values of NA within matR should be handled. See Value for more details.

Value

A logical vector of length ncol(matR), with values of FALSE corresponding to non-reproductive stages and values of TRUE corresponding to reproductive stages.

For a given matrix stage (i.e., column of matR), if there are any positive values of reproduction, the function will return TRUE. However, for a given stage, if there are no positive values of reproduction and one or more values of NA, the function will return NA if na_handling == "return.na", TRUE if na_handling == "return.true", or FALSE if na_handling == "return.false".

Author(s)

Rob Salguero-Gomez <rob.salguero@zoo.ox.ac.uk>

Patrick Barks <patrick.barks@gmail.com>

See Also

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

Examples

matR1 <- rbind(
  c(0, 0.2, 0, 0.5),
  c(0, 0.3, 0, 0.6),
  c(0, 0, 0, 0),
  c(0, 0, 0, 0)
)

matR2 <- rbind(
  c(NA, NA, NA, 1.1),
  c(0, 0, 0.3, 0.7),
  c(0, 0, 0, 0),
  c(0, 0, 0, 0)
)

repro_stages(matR1)

# compare different methods for handling NA
repro_stages(matR2, na_handling = "return.na")
repro_stages(matR2, na_handling = "return.true")
repro_stages(matR2, na_handling = "return.false")

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