This function identifies records out-of-range collecting year (e.g., in the future) or old records collected before a year informed in 'year_threshold'.

bdc_year_outOfRange(data, eventDate, year_threshold = 1900)

Arguments

data

A data frame containing a column with event date information.

eventDate

numeric or date. The column containing event date information.

year_threshold

numeric. A four-digit year threshold used to flag old (potentially invalid) records. Records collected in the threshold year itself are compliant. Default = 1900

Value

A data.frame containing the column ".year_outOfRange". Compliant (TRUE) if 'eventDate' is not out-of-range; otherwise "FALSE".

Details

Following the "VALIDATION:YEAR_OUTOFRANGE" Biodiversity data quality group, the results of this test are time-dependent. While the user may provide a lower limit to the year, the upper limit is defined based on the year when the test is run. Lower limits can be used to flag old, often imprecise, records. For example, records collected before GPS advent (1980). If 'year_threshold' is not provided, the lower limit to the year is by default 1600, a lower limit for collecting dates of biological specimens. The lower limit is inclusive: a record collected in 'year_threshold' (or in 1600 when 'year_threshold' is NULL) is compliant. Records collected after the current year are flagged.

Records with empty or NA 'eventDate' are not tested and returned as TRUE (compliant), whether or not 'year_threshold' is provided. Use bdc_eventDate_empty to flag records with missing dates.

Examples

collection_date <- c(
  NA, "31/12/2029", "2013-06-13T00:00:00Z", "2013-06-20",
  "", "2013", 1650, "0001-01-00"
)
x <- data.frame(collection_date)

bdc_year_outOfRange(
  data = x,
  eventDate = "collection_date",
  year_threshold = 1900
)
#> 
#> bdc_year_outOfRange:
#> Flagged 3 records.
#> One column was added to the database.
#>        collection_date .year_outOfRange
#> 1                 <NA>             TRUE
#> 2           31/12/2029            FALSE
#> 3 2013-06-13T00:00:00Z             TRUE
#> 4           2013-06-20             TRUE
#> 5                                  TRUE
#> 6                 2013             TRUE
#> 7                 1650            FALSE
#> 8           0001-01-00            FALSE