From e1139f2a40bcef6dae7b13027686805dac22d802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zo=C3=AB=20Turnergit=20config=20--global=20user=2Eemail=20?= =?UTF-8?q?zoe=2Eturner2=40nottshc=2Enhs=2Euk=7E/=2Egitconfig=7E/=2Egitcon?= =?UTF-8?q?fig=7E/=2Egitconfiggit=20config=20--global=20user=2Ename=20Zo?= =?UTF-8?q?=C3=AB?= Date: Fri, 29 Oct 2021 21:19:53 +0100 Subject: [PATCH] Vignette for year_date() --- .gitignore | 1 + DESCRIPTION | 2 ++ vignettes/.gitignore | 2 ++ vignettes/date_helper.Rmd | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 vignettes/.gitignore create mode 100644 vignettes/date_helper.Rmd diff --git a/.gitignore b/.gitignore index 9168bf8..16add95 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .httr-oauth .DS_Store docs +inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index c6eb927..1436813 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,6 +15,7 @@ LazyData: true Roxygen: list(markdown = TRUE) RoxygenNote: 7.1.2 Suggests: + rmarkdown, testthat (>= 3.0.0) Config/testthat/edition: 3 Imports: @@ -38,3 +39,4 @@ Remotes: mitchelloharawild/icons, gadenbuie/xaringanExtra, nhs-r-community/nhsrtheme +VignetteBuilder: knitr diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/date_helper.Rmd b/vignettes/date_helper.Rmd new file mode 100644 index 0000000..9e83067 --- /dev/null +++ b/vignettes/date_helper.Rmd @@ -0,0 +1,36 @@ +--- +title: "date_helper" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{date_helper} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r setup} +library(nottshcMethods) +library(NHSRdatasets) +``` + +# ONS Mortality + +Using the {NHSRdatasets} package and particularly the ons_mortality dataset, this finds the earliest and latest years in the dataset, useful for showing or referring to the date range in a dataset. + +The function works with date, integer and character formats if the date is in the format yyyy-mm-dd, for example: + +The ons_mortality dataset is from `r year_date(ons_mortality, date, type = "earliest")` to `year_date(ons_mortality, date, type = "latest")` + +```{r} + +year_date(ons_mortality, date, type = "earliest") +year_date(ons_mortality, date, type = "latest") + +``` +