Skip to content

Commit

Permalink
fix pop sample
Browse files Browse the repository at this point in the history
  • Loading branch information
edward-burn committed Nov 14, 2024
1 parent 9404ad0 commit c449eda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions R/populationDiagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ populationDiagnostics <- function(cohort,
denominatorTable <- omopgenerics::uniqueTableName()

# add population sampling
if(!is.null(populationSample)){
cli::cli_bullets(c("*" = "{.strong Sampling person table to {populationSample}}"))
cdm$person <- cdm$person |>
dplyr::slice_sample(n = populationSample)
}

cdm <- IncidencePrevalence::generateDenominatorCohortSet(
cdm = cdm,
Expand Down
4 changes: 3 additions & 1 deletion tests/testthat/test-populationDiagnostics.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
test_that("population incidence and prevalence", {
cdm <- IncidencePrevalence::mockIncidencePrevalenceRef(sampleSize = 1000)
cdm <- IncidencePrevalence::generateDenominatorCohortSet(cdm, name = "denom")
expect_no_error(pop_diag <- populationDiagnostics(cohort = cdm$outcome,
expect_no_error(pop_diag_sample <- populationDiagnostics(cohort = cdm$outcome,
populationSample = 250))
expect_no_error(pop_diag_no_sample <- populationDiagnostics(cohort = cdm$outcome,
populationSample = NULL))

CDMConnector::cdm_disconnect(cdm)

Expand Down

0 comments on commit c449eda

Please sign in to comment.