From 031e1e62bf6fcf20ebb89c19b824a05cce72c6c3 Mon Sep 17 00:00:00 2001 From: James McMahon Date: Mon, 14 Aug 2023 14:05:07 +0100 Subject: [PATCH 1/3] Add tests for `compute_mid_year_age` --- tests/testthat/test-compute_mid_year_age.R | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tests/testthat/test-compute_mid_year_age.R diff --git a/tests/testthat/test-compute_mid_year_age.R b/tests/testthat/test-compute_mid_year_age.R new file mode 100644 index 000000000..a4a542b9e --- /dev/null +++ b/tests/testthat/test-compute_mid_year_age.R @@ -0,0 +1,16 @@ +test_that("Accurately compute mid year age", { + expect_equal( + compute_mid_year_age("1718", lubridate::make_date("2000")), + phsmethods::age_calculate( + lubridate::make_date("2000"), + lubridate::make_date("2017", 9L, 30L) + ) + ) + expect_equal( + compute_mid_year_age("2021", lubridate::make_date("1999") + 1:1000), + phsmethods::age_calculate( + lubridate::make_date("1999") + 1:1000, + lubridate::make_date("2020", 9L, 30L) + ) + ) +}) From 94ed2057449db72b5dc6757ac10b0ea46db3145c Mon Sep 17 00:00:00 2001 From: James McMahon Date: Mon, 14 Aug 2023 15:07:01 +0100 Subject: [PATCH 2/3] Remove redundant code --- R/compute_mid_year_age.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/compute_mid_year_age.R b/R/compute_mid_year_age.R index 01bfaf5d5..0e2483cf7 100644 --- a/R/compute_mid_year_age.R +++ b/R/compute_mid_year_age.R @@ -20,7 +20,7 @@ compute_mid_year_age <- function(fyyear, dob) { age_intervals <- lubridate::interval( start = dob, - end = as.Date(midpoint_fy(fyyear)) + end = midpoint_fy(fyyear) ) ages <- lubridate::as.period(age_intervals)$year From 6279148b83efd13d00210b1e8f7eba3e7d8140ef Mon Sep 17 00:00:00 2001 From: Jennit07 Date: Mon, 25 Sep 2023 07:48:11 +0000 Subject: [PATCH 3/3] Update documentation --- man/read_file.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/read_file.Rd b/man/read_file.Rd index b8231218f..1ef351342 100644 --- a/man/read_file.Rd +++ b/man/read_file.Rd @@ -14,7 +14,7 @@ read_file(path, col_select = NULL, as_data_frame = TRUE, ...) \link[tidyselect:eval_select]{tidy selection specification} of columns, as used in \code{dplyr::select()}.} -\item{as_data_frame}{Should the function return a \code{data.frame} (default) or +\item{as_data_frame}{Should the function return a \code{tibble} (default) or an Arrow \link[arrow]{Table}?} \item{...}{Addition arguments passed to the relevant function.}