
Set, create or modify columns with information of individual organisms
Source:R/set_individual_traits.R
set_individual_traits.RdFormat fields that contain measurements or attributes of individual
organisms to a tibble using Darwin Core Standard. Fields include those
that specify sex, life stage or condition. Individuals can be identified by
an individualID if data contains resampling.
In practice this is no different from using mutate(), but gives some
informative errors, and serves as a useful lookup for fields in
the Darwin Core Standard.
Usage
set_individual_traits(
.df,
individualID = NULL,
lifeStage = NULL,
sex = NULL,
vitality = NULL,
reproductiveCondition = NULL,
.keep = "unused"
)Arguments
- .df
A
data.frameortibblethat the column should be appended to.- individualID
An identifier for an individual or named group of individual organisms represented in the Occurrence. Meant to accommodate resampling of the same individual or group for monitoring purposes. May be a global unique identifier or an identifier specific to a data set.
- lifeStage
The age class or life stage of an organism at the time of occurrence.
- sex
The sex of the biological individual.
- vitality
An indication of whether an organism was alive or dead at the time of collection or observation.
- reproductiveCondition
The reproductive condition of the biological individual.
- .keep
Control which columns from .data are retained in the output. Note that unlike
dplyr::mutate(), which defaults to"all"this defaults to"unused"; i.e. only keeps Darwin Core columns, and not those columns used to generate them.
Details
Examples of lifeStage values:
zygotelarvaadultseedlingflowering
Examples of vitality values:
alivedeaduncertain
Examples of reproductiveCondition values:
non-reproductivepregnantin bloomfruit bearing
See also
set_scientific_name() for adding scientificName and authorship information.
Examples
df <- tibble::tibble(
name = c("Crinia Signifera", "Crinia Signifera", "Litoria peronii"),
latitude = c(-35.27, -35.24, -35.83),
longitude = c(149.33, 149.34, 149.34),
eventDate = c("2010-10-14", "2010-10-14", "2010-10-14"),
id = c(4421, 4422, 3311),
life_stage = c("juvenile", "adult", "adult")
)
# Reformat columns to Darwin Core Standard
df |>
set_individual_traits(
individualID = id,
lifeStage = life_stage
)
#> ⠙ Checking 2 columns: individualID and lifeStage
#> ⠹ Checking 2 columns: individualID and lifeStage
#> ✔ Checking 2 columns: individualID and lifeStage [635ms]
#>
#> # A tibble: 3 × 6
#> name latitude longitude eventDate individualID lifeStage
#> <chr> <dbl> <dbl> <chr> <dbl> <chr>
#> 1 Crinia Signifera -35.3 149. 2010-10-14 4421 juvenile
#> 2 Crinia Signifera -35.2 149. 2010-10-14 4422 adult
#> 3 Litoria peronii -35.8 149. 2010-10-14 3311 adult