A function made to search other columns for dates and add them to the eventDate column. The function searches the columns locality, fieldNotes, locationRemarks, and verbatimEventDate for the relevant information.

dateFindR(data = NULL, maxYear = lubridate::year(Sys.Date()), minYear = 1700)

Arguments

data

A data frame or tibble. Occurrence records as input.

maxYear

Numeric. The maximum year considered reasonable to find. Default = lubridate::year(Sys.Date()).

minYear

Numeric. The minimum year considered reasonable to find. Default = 1700.

Value

The function results in the input occurrence data with but with updated eventDate, year, month, and day columns for occurrences where these data were a) missing and b) located in one of the searched columns.

Examples

# Using the example dataset, you may not find any missing eventDates are rescued (dependent on 
# which version of the example dataset the user inputs.
beesRaw_out <- dateFindR(data = beesRaw,
                         # Years above this are removed (from the recovered dates only)
                         maxYear = lubridate::year(Sys.Date()),
                         # Years below this are removed (from the recovered dates only)
                         minYear = 1700)
#>  - Preparing data...
#>  - Extracting dates from year, month, day columns...
#>  - Extracting dates from fieldNotes, locationRemarks, and verbatimEventDate columns in unambiguous ymd, dmy, mdy, and my formats...
#>  - Extracting year from fieldNotes, locationRemarks, and verbatimEventDate columns in ambiguous formats...
#>  - Formating and combining the new data..
#> Warning:  6 failed to parse.
#>  - Merging all data, nearly there...
#>  - Finished. 
#> We now have -5 more full eventDate cells than in the input data.
#> We modified dates in 
#> 89 occurrences.
#>  - As it stands, there are 83 complete eventDates and 17 missing dates.
#>  - There are also 89 complete year occurrences to filter from. This is up from an initial count of 88 At this rate, you will stand to lose 11 occurrences on the basis of missing year - Operation time: 0.172427654266357 secs