Adds user-supplied or automatically-generated stage names to a matrix population model (MPM).
name_stages(mat, names = NULL, prefix = "stage_", left_pad = TRUE)An MPM, either as a single matrix or list of matrices.
A character vector specifying the name of each life stage, in
order. If provided, prefix and left_pad arguments are
ignored.
A string to be pre-pended to the stage number when
automatically naming stages. Defaults to stage_.
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.
The input matrix or matrices with named rows and columns.
Other transformation:
is_leslie_matrix(),
leslie_collapse(),
mpm_collapse(),
mpm_rearrange(),
mpm_split(),
mpm_standardize(),
repro_stages(),
standard_stages()
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)
#> stage_1 stage_2 stage_3
#> stage_1 0.0 0.0 0.0
#> stage_2 0.3 0.1 0.0
#> stage_3 0.0 0.5 0.8
name_stages(matU, prefix = "s")
#> s1 s2 s3
#> s1 0.0 0.0 0.0
#> s2 0.3 0.1 0.0
#> s3 0.0 0.5 0.8
# custom stage names
name_stages(matU, names = c("small", "medium", "large"))
#> Warning: Naming `prefix` ignored, using stage `names` instead.
#> small medium large
#> small 0.0 0.0 0.0
#> medium 0.3 0.1 0.0
#> large 0.0 0.5 0.8
# overwrite existing stage names
data(mpm1)
name_stages(mpm1)
#> Warning: Existing stage names have been overwritten!
#> $matU
#> stage_1 stage_2 stage_3 stage_4 stage_5
#> stage_1 0.10 0.00 0.00 0.00 0.00
#> stage_2 0.05 0.12 0.10 0.00 0.00
#> stage_3 0.00 0.35 0.12 0.23 0.12
#> stage_4 0.00 0.03 0.28 0.52 0.10
#> stage_5 0.00 0.00 0.16 0.11 0.17
#>
#> $matF
#> stage_1 stage_2 stage_3 stage_4 stage_5
#> stage_1 0 0 17.9 45.6 0
#> stage_2 0 0 0.0 0.0 0
#> stage_3 0 0 0.0 0.0 0
#> stage_4 0 0 0.0 0.0 0
#> stage_5 0 0 0.0 0.0 0
#>