Skip to contents

This function helps format standard date/time fields to a tibble.

Usage

use_datetime(
  .df,
  eventDate = NULL,
  year = NULL,
  month = NULL,
  day = NULL,
  eventTime = NULL,
  .keep = "unused",
  .messages = TRUE
)

Arguments

.df

a data.frame or tibble that the column should be appended to.

eventDate

The date or date + time that the observation/event occurred.

year

The year of the observation/event.

month

The month of the observation/event.

day

The day of the observation/event.

eventTime

The time of the observation/event.

.keep

Control which columns from .data are retained in the output. Note that unlike dplyr::mutate(), which defaults to "all" this defaults to "unused"; i.e. only keeps Darwin Core fields, and not those fields used to generate them.

.messages

(logical) Should informative messages be shown? Defaults to TRUE.

Value

A tibble with the requested fields added.

Details

In practice this is no different from using mutate(), but gives some informative errors, and serves as a useful lookup for how spatial fields are represented in the Darwin Core Standard.

Example values are:

  • eventDate should be class Date or POSITct. We suggest using the lubridate package to define define your date format using functions like ymd(), mdy, dmy(), or if including date + time, ymd_hms(), ymd_hm(), or ymd_h().