as_date_ecotox {ECOTOXr}R Documentation

Values represented by ECOTOX character to dates

Description

[Experimental] Similar to as.Date(), but it also performs some text sanitising before coercing text to dates.

Usage

as_date_ecotox(x, dd = 1L, mm = 1L, nr = 1L, ..., warn = TRUE)

Arguments

x

A vector of character strings. It expects fields as commonly returned from the ECOTOX database.

dd

Replacement values for unspecified days in a date. Defaults to 1L. If you want dates with unspecified days to result in NA, use dd = -1L.

mm

Replacement values for unspecified months in a date. Defaults to 1L. If you want dates with unspecified months to result in NA, use mm = -1L.

nr

Replacement values for generically unspecified values in a date. Defaults to 1L. If you want dates with unspecified values to result in NA, use nr = -1L.

...

Passed to as.Date().

warn

If set to FALSE warnings while converting text to dates are suppressed.

Details

The following steps are performed (in the order as listed) to sanitise text before coercing it to numerics:

It is your own responsibility to check if the sanitising steps are appropriate for your analyses.

Value

A vector of Date class objects with the same length as x.

Author(s)

Pepijn de Vries

See Also

Other ecotox-sanitisers: as_numeric_ecotox(), as_unit_ecotox(), mixed_to_single_unit(), process_ecotox_dates(), process_ecotox_numerics(), process_ecotox_units()

Examples

## a vector of commonly used notations in the database to represent
## dates. Most frequent format is %m/%d/%Y
char_date <- c("5-19-1987   ", "5/dd/2021", "3/19/yyyy", "1985", "mm/19/1999",
               "October 2004", "nr/nr/2015")

as_date_ecotox(char_date)

## Set unspecified days to 15:
as_date_ecotox(char_date, dd = 15L)

## Unspecified days should result in NA:
as_date_ecotox(char_date, dd = -1L)

## Set unspecified months to 6:
as_date_ecotox(char_date, mm = 6L)

## Set generically unspecified value to 6:
as_date_ecotox(char_date, nr = 6L)

[Package ECOTOXr version 1.2.1 Index]