Skip to contents

[Experimental] The function search_ecotox() returns fields from the ECOTOX database as is. Many numeric values are stored in the database as text. It is not uncommon that these text fields cannot be converted directly and need some sanitising first. process_ecotox_numerics() takes a data.frame returned by search_ecotox(), locates numeric columns, represented by text, sanitises the text and converts them to numerics.

Usage

process_ecotox_numerics(x, .fns = as_numeric_ecotox, ..., .names = NULL)

Arguments

x

A data.frame obtained with search_ecotox(), for which the numerics need to be processed.

.fns

Function to convert character to numeric. By default as_numeric_ecotox() is used which also sanitises the input. You can also use as.numeric() if you don't want the sanitation step. You can also write a custom function.

...

Arguments passed to .fns.

.names

A 'glue' specification used to rename the numeric columns. By default it is "{.col}", which will overwrite existing text columns with numeric columns. You can for instance add a suffix with "{.col}_num" if you want to rename the resulting numeric columns.

Value

Returns a data.frame in which the columns containing numeric information is converted from the character format from the database to actual numerics.

Author

Pepijn de Vries

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_num <-
    process_ecotox_numerics(df, warn = FALSE)
}