knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(nottshcMethods)

Dummy Data

This create a dummy data for this experimentation

# Fix the randomness to ensure same data is generated every time
set.seed(123)

dummy_data <- data.frame(
  date = sample(seq(as.Date("2000/01/01"), by = "week", length.out = 10 * 12 * 4),
    size = 52 * 4
  )
)

Using the dummy dataset created above, this finds the earliest and latest years in the dataset, useful for showing or referring to the date range in a dataset.

year_date(dummy_data, date, type = "earliest")
year_date(dummy_data, date, type = "latest")


CDU-data-science-team/nottshcMethods documentation built on March 19, 2023, 11:54 a.m.