tests/testthat/test-bdc_year_from_eventDate.R

collection_date <-
  c(
    NA,
    "31/12/2015",
    "2013-06-13T00:00:00Z",
    "2013-06-20",
    "",
    "2013",
    "0001-01-00"
  )

x <- data.frame(collection_date)

test_that("bdc_year_from_eventDate can detect four-digits year", {
  resultant <-
    bdc_year_from_eventDate(data = x, eventDate = "collection_date")

  expect_equal(resultant$year, c(NA, 2015, 2013, 2013, NA, 2013, 1))
})

Try the bdc package in your browser

Any scripts or data that you put into this service are public.

bdc documentation built on April 3, 2025, 10:53 p.m.