ranks_to_numeric: Convert NatureServe S ranks to numeric

Description Usage Arguments Value Examples

View source: R/process_rank.R

Description

Converts NatureServ S ranks to a number from 0 ("SX") to 5 ("S5"). Historic ("SH") is converted to 0.5 (i.e., halfway between 0 and 1). When there are range ranks they are converted to a numeric vector (e.g., "S2S4" becomes c(2,3,4))

Usage

1
2
3
4
5
6
ranks_to_numeric(
  ranks,
  simplify = FALSE,
  round_fun = stats::median,
  keep = "B"
)

Arguments

ranks

character vector of input S ranks

simplify

converts list to numeric vector, and rounds range ranks using the function supplied to round_fun. Default = FALSE

round_fun

what function to use (default median) to round range ranks into a single value when simplify is TRUE. Ignored if simplify is FALSE.

keep

which component to of a rank with multiple ranks for different breeding statuses. "B" = breeding, "M" = migratory, "N" = non-breeding

Value

a list the same length as ranks of numeric vectors. For range ranks, the vector will be sequence from low to high (e.g.,"S3S5" becomes c(3,4,5))

Examples

1
2
ranks_to_numeric(c("S1", "SX", "S2S4", "SH", "S2?", "S3B,S2N"))
ranks_to_numeric(c("S1", "SX", "S2S4", "SH", "S2?", "S3B,S2N"), keep = "N")

bcgov/ranktrends documentation built on Dec. 20, 2020, 7:18 a.m.