Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates documentation of dateRange #307

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Imports:
tibble,
tidyr
Depends:
R (>= 4.1.0)
R (>= 4.1)
URL: https://OHDSI.github.io/OmopSketch/
BugReports: https://github.com/OHDSI/OmopSketch/issues
VignetteBuilder: knitr
Expand Down
12 changes: 12 additions & 0 deletions R/documentationHelper.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Argument descriptions repeated > 1:

#' Helper for consistent documentation of `dateRange`.
#'
#' @param dateRange A vector of two dates defining the desired study period.
#' Only the `start_date` column of the OMOP table is checked to ensure it falls within this range.
#' If `dateRange` is `NULL`, no restriction is applied.
#'
#'
#' @name dateRange-startDate
#' @keywords internal
NULL
3 changes: 1 addition & 2 deletions R/summariseClinicalRecords.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
#' @param ageGroup A list of age groups to stratify results by.
#' @param sex Boolean variable. Whether to stratify by sex (TRUE) or not
#' (FALSE).
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @inheritParams dateRange-startDate
#' @return A summarised_result object.
#' @export
#' @examples
Expand Down
3 changes: 1 addition & 2 deletions R/summariseConceptCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#' @param sex TRUE or FALSE. If TRUE code use will be summarised by sex.
#' @param ageGroup A list of ageGroup vectors of length two. Code use will be
#' thus summarised by age groups.
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @inheritParams dateRange-startDate
#'
#' @return A summarised_result object with results overall and, if specified, by
#' strata.
Expand Down
3 changes: 1 addition & 2 deletions R/summariseConceptIdCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#' thus summarised by age groups.
#' @param sample An integer to sample the tables to only that number of records.
#' If NULL no sample is done.
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @inheritParams dateRange-startDate
#'
#' @return A summarised_result object with results overall and, if specified, by
#' strata.
Expand Down
3 changes: 1 addition & 2 deletions R/summariseConceptSetCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#' @param sex TRUE or FALSE. If TRUE code use will be summarised by sex.
#' @param ageGroup A list of ageGroup vectors of length two. Code use will be
#' thus summarised by age groups.
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @inheritParams dateRange-startDate
#' @return A summarised_result object with results overall and, if specified, by
#' strata.
#' @export
Expand Down
3 changes: 1 addition & 2 deletions R/summariseInObservation.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#' @param ageGroup A list of age groups to stratify results by.
#' @param sex Boolean variable. Whether to stratify by sex (TRUE) or not
#' (FALSE).
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @inheritParams dateRange-startDate
#' @return A summarised_result object.
#' @export
#' @examples
Expand Down
3 changes: 1 addition & 2 deletions R/summariseMissingData.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
#' thus summarised by age groups.
#' @param sample An integer to sample the table to only that number of records.
#' If NULL no sample is done.
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @inheritParams dateRange-startDate
#'
#' @return A summarised_result object with results overall and, if specified, by
#' strata.
Expand Down
3 changes: 1 addition & 2 deletions R/summariseObservationPeriod.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#' @param ageGroup A list of age groups to stratify results by.
#' @param sex Boolean variable. Whether to stratify by sex (TRUE) or not
#' (FALSE).
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @inheritParams dateRange-startDate
#'
#' @return A summarised_result object with the summarised data.
#'
Expand Down
3 changes: 1 addition & 2 deletions R/summariseRecordCount.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#' @param interval Time interval to stratify by. It can either be "years", "quarters", "months" or "overall".
#' @param ageGroup A list of age groups to stratify results by.
#' @param sex Whether to stratify by sex (TRUE) or not (FALSE).
#' @param dateRange A list containing the minimum and the maximum dates
#' defining the time range within which the analysis is performed.
#' @inheritParams dateRange-startDate
#' @param sample An integer to sample the tables to only that number of records.
#' If NULL no sample is done.
#' @return A summarised_result object.
Expand Down
14 changes: 14 additions & 0 deletions man/dateRange-startDate.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/summariseClinicalRecords.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/summariseConceptCounts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/summariseConceptIdCounts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/summariseConceptSetCounts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/summariseInObservation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/summariseMissingData.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/summariseObservationPeriod.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions man/summariseRecordCount.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions tests/testthat/test-summariseConceptSetCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -562,26 +562,26 @@ test_that("dateRange argument works", {
test_that("interval argument works", {
skip_on_cran()
# Load mock database ----
cdm <- mockOmopSketch()
expect_no_error(y<-summariseConceptSetCounts(list(ANTIHISTAMINES= c(21603444)),
cdm <- cdmEunomia()
expect_no_error(y<-summariseConceptSetCounts(list("polio" = c(40213160)),
cdm = cdm,
interval = "years"))

expect_no_error(o<-summariseConceptSetCounts(list(ANTIHISTAMINES= c(21603444)),
expect_no_error(o<-summariseConceptSetCounts(list("polio" = c(40213160)),
cdm = cdm,
interval = "overall"))
expect_no_error(q<-summariseConceptSetCounts(list(ANTIHISTAMINES= c(21603444)),
expect_no_error(q<-summariseConceptSetCounts(list("polio" = c(40213160)),
cdm = cdm,
interval = "quarters"))
expect_no_error(m<-summariseConceptSetCounts(list(ANTIHISTAMINES= c(21603444)),
expect_no_error(m<-summariseConceptSetCounts(list("polio" = c(40213160)),
cdm = cdm,
interval = "months"))



m_quarters <- m|>omopgenerics::splitAdditional()|>
omopgenerics::pivotEstimates() |>
dplyr::filter(time_interval != "overall" & variable_name == "Number records" & standard_concept_id == 21603444) |>
dplyr::filter(time_interval != "overall" & variable_name == "Number records" & standard_concept_id == 40213160) |>
dplyr::mutate(
start_date = as.Date(sub(" to .*", "", time_interval)),
quarter_start = lubridate::quarter(start_date, type = "date_first"),
Expand All @@ -596,15 +596,15 @@ test_that("interval argument works", {

q_quarters <- q|>omopgenerics::splitAdditional()|>
omopgenerics::pivotEstimates()|>
dplyr::filter(time_interval != "overall" & variable_name == "Number records"& standard_concept_id == 21603444)|>
dplyr::filter(time_interval != "overall" & variable_name == "Number records"& standard_concept_id == 40213160)|>
dplyr::select(time_interval, count)|>
dplyr::arrange(time_interval)

expect_equal(m_quarters, q_quarters)

m_year <- m|>
omopgenerics::splitAdditional()|>
dplyr::filter(time_interval != "overall" & variable_name == "Number records" & standard_concept_id == 21603444)|>
dplyr::filter(time_interval != "overall" & variable_name == "Number records" & standard_concept_id == 40213160)|>
dplyr::mutate(
# Extract the start date
start_date = clock::date_parse(stringr::str_extract(time_interval, "^\\d{4}-\\d{2}-\\d{2}")),
Expand All @@ -620,7 +620,7 @@ test_that("interval argument works", {
dplyr::arrange(year)
y_year <- y|>
omopgenerics::splitAdditional()|>
dplyr::filter(time_interval != "overall" & variable_name == "Number records" & standard_concept_id == 21603444)|>
dplyr::filter(time_interval != "overall" & variable_name == "Number records" & standard_concept_id == 40213160)|>
dplyr::mutate(
# Extract the start date
start_date = clock::date_parse(stringr::str_extract(time_interval, "^\\d{4}-\\d{2}-\\d{2}")),
Expand All @@ -633,7 +633,7 @@ test_that("interval argument works", {

expect_equal(m_year, y_year)
o <- o |> omopgenerics::splitAdditional()|>
dplyr::filter(variable_name == "Number records" & standard_concept_id == 21603444)|>
dplyr::filter(variable_name == "Number records" & standard_concept_id == 40213160)|>
omopgenerics::pivotEstimates()|>
dplyr::select(count)

Expand All @@ -642,7 +642,7 @@ test_that("interval argument works", {

q_year <- q|>
omopgenerics::splitAdditional()|>
dplyr::filter(time_interval != "overall" & variable_name == "Number records" & standard_concept_id == 21603444)|>
dplyr::filter(time_interval != "overall" & variable_name == "Number records" & standard_concept_id == 40213160)|>
dplyr::mutate(
# Extract the start date
start_date = clock::date_parse(stringr::str_extract(time_interval, "^\\d{4}-\\d{2}-\\d{2}")),
Expand Down
Loading