category | R Documentation |
Convenience functions to quickly specify and identify biological categories and species groups. These are defined by sex, size, maturity or other biological characteristics.
category(x, ...)
## Default S3 method:
category(x, ...)
## S3 method for class 'numeric'
category(x, sex, group, ...)
## S3 method for class 'character'
category(x, parse = FALSE, ...)
is.category(x, ...)
## S3 method for class 'scsbio'
is.category(x, category, drop = TRUE, ...)
is.fish(species)
is.invertebrate(species)
is.skate(species)
is.shrimp(species)
x |
Character string(s) specifying a biological categories or an‘scsbio’ object.
The full syntax of biological strings are presented in the |
... |
Further argument (e.g. |
sex |
A scalar specifying the sex category of the default values to be returned if
|
parse |
Logical value specifying whether to parse a category string onto a list containing the corresponding variable definitions, suitable for direct indexing of biological fields. |
drop |
Logical values specifying whether to convert index to a vector from a data frame
when only a single category is specified in |
species |
Numerical species code(s). |
language |
A character string specifying the language in which category code descriptions
are to be returned. Either english ( |
symbols |
Logical value specifying whether arithmetic operators are to be used in category descriptions. |
simplify |
Logical value specifying whether to simplify category descriptions where possible (e.g. 'skip-moulters'). |
String are not case sensitive. Spaces or other separators may be included in the string for clarity, but have no effect on the output. String syntax is as follows:
Sex
The first character specifies the sex ‘M’ for males and ‘F’ for females.
Maturity
The second character(s) is/are optional and specifies the maturity. It may be either ‘M’ for matures, ‘I’ for immatures, ‘P’ for primiparous, ‘MULT’ for multiparous or ‘SENILE’ for seniles.
Shell condition
Shell condition may be specified using the form ‘SCX’, where ‘X’ is a string of shell condition codes.
Size
Carapace width intervals may be specified using the forms ‘GX’ (greater than or equal to X) and/or ‘LX’ (less than X). In addition, forms such as ‘BTXTOY’, where ‘X’ and ‘Y’ specify lower and upper bounds, respectively. The form ‘FROMXTOY’ is also acceptable.
Gonad colour
Gonad colour may be specified using the form ‘GNX’ where ‘X’ is a valid colour string. Acceptable strings are ‘W’ (White), ‘B’ (Beige) and ‘O’ (Orange).
Egg colour
Egg colour may be specified using the form ‘EX’ where ‘X’ is a valid colour string. Acceptable strings are ‘LO’ (Light Orange), ‘DO’ (Dark Orange) and ‘B’ (Black).
Eggs remaining
Eggs remaining may be specified using the form ‘ELXXP’ or ‘EGXXP’, which correspond to the less-than or greater-or-equal-to forms, respectively. The string ‘X’ is a two-digit percentage of eggs remaining. So crab with eggs remaining less than 50% would be specified using the string ‘EL50P’.
Missing legs
Crabs with missing legs may be targetted by including a ‘ML’ string.
Returns a vector of character strings containing the descriptions for a specified vector of category strings or codes.
category
Generic category
method.
category.default
Default category
method.
category.numeric
Return sets of pre-defined biological category strings.
category.character
Return formal and informal description or formal specification of a biological category string.
is.category
Generic is.category
function.
is.category.scsbio
Returns whether an observation belongs to a specified snow crab biological category.
is.fish
Determine whether a species is an vertebrate fish species.
is.invertebrate
Determine whether a species is an invertebrate.
is.skate
Determine whether a fish species is a skate.
is.shrimp
Determine whether a species was categorized as a shrimp historically.
# Default biological category strings:
category() # All common categories.
category(group = "other") # Other pre-defined categories.
category(sex = "female") # Female category strings.
category(1:10, sex = "male") # First 10 elements of male category strings:
# Get long form description for mature males with carapace width larger or equal to 95mm:
category("MMGE95")
# Mature males, greater or equal than 95mm with shell condition 3,4 or 5 (spaces are ignored):
category("M M GE95 SC345", simplify = FALSE) # Long definition of commercial males.
category("M M GE95 SC345", simplify = TRUE) # Short definition of commercial males.
# Multiparous females with orange gonads:
category("FMULTGNO")
# With multiple entries:
category(c("FM", "FMULTGNO", "MG65ML"))
# Parse category strings:
category("MM", parse = TRUE) # Mature males.
category("MIG95", parse = TRUE) # Immature males larger than 95mm.
category("FPBT35TO60", parse = TRUE) # Primiparous females between 35 and 60mm.
# Snow crab biological data example:
x <- read.scsbio(year = 2020)
index <- is.category(x, "TMMG95") # Mature males greater than 95mm:
# Get number of observations per category:
index <- is.category(x, c("T", "TM", "TF", "TMIL95SC12", "TMMG95", "TFMULT"))
apply(index, 2, sum, na.rm = TRUE)
# Use 'catch' function to generate catch summaries:
catch(x, category = c("T", "M", "F", "MIL95SC12", "MMG95", "FMULT"))
catch(x, category = c("T", "M", "F", "MIL95SC12", "MMG95", "FMULT"), by = "date")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.