Process ECOTOX search results by converting character to units where relevant
Source: R/process_unit.r
process_ecotox_units.Rd The function
search_ecotox() returns fields
from the ECOTOX database as is. Fields that represent units are not standardised in
the database. Therefore, this format is not consistently used throughout the
database. process_ecotox_units() takes a data.frame returned by
search_ecotox(), locates unit columns, represented by text, sanitises the text
and converts them to units::mixed_units() objects. It will sanitise the unit fields as
much as possible. Units that could not be interpreted are returned as arbitrary unit.
Arguments
- x
A
data.frameobtained withsearch_ecotox(), for which the units need to be processed.- .fns
Function to convert
characterto unit. By defaultas_unit_ecotox()is used which also sanitises the input. You can also write a custom function.- ...
Arguments passed to
.fns.- .names
A 'glue' specification used to rename the unit columns. By default it is
"{.col}", which will overwrite existing text columns with unit columns. You can for instance add a suffix with"{.col}_unit"if you want to rename the resulting unit columns.
Value
Returns a data.frame in which the columns containing unit information
is converted from the character format from the database to actual unit objects (
?units::units).
See also
Other ecotox-sanitisers:
as_date_ecotox(),
as_numeric_ecotox(),
as_unit_ecotox(),
mixed_to_single_unit(),
process_ecotox_dates(),
process_ecotox_numerics()
Examples
if (check_ecotox_availability()) {
df <- search_ecotox(
list(
latin_name = list(
terms = c("Skeletonema", "Daphnia"),
method = "contains"
),
chemical_name = list(
terms = "benzene",
method = "exact"
)
), list_ecotox_fields("full"))
df_unit <-
process_ecotox_units(df, warn = FALSE)
}