diff --git a/R/plotObservationPeriod.R b/R/plotObservationPeriod.R index 0a0c66f..5afd46e 100644 --- a/R/plotObservationPeriod.R +++ b/R/plotObservationPeriod.R @@ -20,14 +20,14 @@ #' #' result |> #' plotObservationPeriod( -#' variableName = "duration in days", +#' variableName = "Duration in days", #' plotType = "boxplot" #' ) #' #' PatientProfiles::mockDisconnect(cdm) #' } plotObservationPeriod <- function(result, - variableName = "number subjects", + variableName = "Number subjects", plotType = "barplot", facet = NULL, colour = NULL) { @@ -110,13 +110,13 @@ plotObservationPeriod <- function(result, availablePlotObservationPeriod <- function() { dplyr::tribble( ~variable_name, ~plot_type, ~facet, - "number subjects", "barplot", "cdm_name+observation_period_ordinal", - "records per person", "densityplot", "cdm_name", - "records per person", "boxplot", "cdm_name", - "duration in days", "densityplot", "cdm_name+observation_period_ordinal", - "duration in days", "boxplot", "cdm_name+observation_period_ordinal", - "days to next observation period", "densityplot", "cdm_name+observation_period_ordinal", - "days to next observation period", "boxplot", "cdm_name+observation_period_ordinal", + "Number subjects", "barplot", "cdm_name+observation_period_ordinal", + "Records per person", "densityplot", "cdm_name", + "Records per person", "boxplot", "cdm_name", + "Duration in days", "densityplot", "cdm_name+observation_period_ordinal", + "Duration in days", "boxplot", "cdm_name+observation_period_ordinal", + "Days to next observation period", "densityplot", "cdm_name+observation_period_ordinal", + "Days to next observation period", "boxplot", "cdm_name+observation_period_ordinal", ) } needEstimates <- function(plotType) { diff --git a/R/summariseAllConceptCounts.R b/R/summariseAllConceptCounts.R index bd3befc..fe459cd 100644 --- a/R/summariseAllConceptCounts.R +++ b/R/summariseAllConceptCounts.R @@ -101,7 +101,10 @@ summariseAllConceptCounts <- function(cdm, ) |> # summarise results summariseCountsInternal(stratax, counts) |> - dplyr::mutate(omop_table = .env$table) + dplyr::mutate(omop_table = .env$table, + estimate_name = dplyr::if_else(.data$estimate_name == "count_records", "Number records", + dplyr::if_else(.data$estimate_name == "count_subjects", "Number subjects", .data$estimate_name) + )) omopgenerics::dropSourceTable(cdm = cdm, name = dplyr::starts_with(prefix)) diff --git a/R/summariseClinicalRecords.R b/R/summariseClinicalRecords.R index 6edd1bf..7be760b 100644 --- a/R/summariseClinicalRecords.R +++ b/R/summariseClinicalRecords.R @@ -163,7 +163,7 @@ summariseClinicalRecords <- function(cdm, # Summary if (inObservation | standardConcept | sourceVocabulary | domainId | typeConcept) { denominator <- resultsRecordPerPerson |> - dplyr::filter(.data$variable_name == "number records") |> + dplyr::filter(.data$variable_name == "Number records") |> dplyr::select("strata_name", "strata_level", den = "estimate_value") variables <- variablesToSummarise( inObservation, standardConcept, sourceVocabulary, domainId, typeConcept @@ -258,7 +258,7 @@ summariseClinicalRecords <- function(cdm, dplyr::select("strata_name", "strata_level") |> dplyr::distinct() |> dplyr::cross_join(dplyr::tibble(variable_name = unique(c( - "number subjects", "number records", "records_per_person", + "Number subjects", "Number records", "records_per_person", unique(fullResult$variable_name) )))) |> dplyr::mutate(order_id = dplyr::row_number()) |> @@ -319,17 +319,18 @@ summariseRecordsPerPerson <- function(x, den, strata, estimates) { variables = list("number_subjects", "n"), estimates = list(c("count", "percentage"), c(estimates, "sum")) ) |> - suppressMessages() - }) |> + suppressMessages() |> + dplyr::mutate(variable_name = dplyr::if_else(.data$variable_name == "number subjects", "Number subjects", .data$variable_name)) +}) |> dplyr::bind_rows() |> dplyr::mutate( variable_name = dplyr::if_else( .data$variable_name == "n", - dplyr::if_else(.data$estimate_name == "sum", "number records", "records_per_person"), + dplyr::if_else(.data$estimate_name == "sum", "Number records", "records_per_person"), .data$variable_name ), estimate_name = dplyr::if_else( - .data$variable_name == "number records", "count", .data$estimate_name + .data$variable_name == "Number records", "count", .data$estimate_name ), estimate_value = reduceDemicals(.data$estimate_value, 4) ) diff --git a/R/summariseInternal.R b/R/summariseInternal.R index a9371ce..96de687 100644 --- a/R/summariseInternal.R +++ b/R/summariseInternal.R @@ -5,7 +5,7 @@ summariseCountsInternal <- function(x, strata, counts) { 'dplyr::n_distinct(.data$person_id)', 'dplyr::n_distinct(.data$subject_id)' ) |> - rlang::set_names(c("count_records", "count_subjecst", "count_subjects")) |> + rlang::set_names(c("count_records", "count_subjects", "count_subjects")) |> purrr::keep(c("records", "person_id", "subject_id") %in% counts) |> rlang::parse_exprs() purrr::map(strata, \(stratak) { diff --git a/R/summariseObservationPeriod.R b/R/summariseObservationPeriod.R index 3d9743b..d0fc03f 100644 --- a/R/summariseObservationPeriod.R +++ b/R/summariseObservationPeriod.R @@ -93,6 +93,8 @@ summariseObservationPeriod <- function(observationPeriod, estimates = estimates ) |> suppressMessages() |> + dplyr::mutate(variable_name = dplyr::if_else(.data$variable_name == "number records", "Number records", + dplyr::if_else(.data$variable_name == "number subjects", "Number subjects" , .data$variable_name))) |> dplyr::union_all( obs |> dplyr::group_by(.data$person_id, dplyr::across(dplyr::any_of(c("sex","age_group")))) |> @@ -107,7 +109,7 @@ summariseObservationPeriod <- function(observationPeriod, suppressMessages() ) |> addOrdinalLevels() |> - dplyr::filter(.data$variable_name != "number records" | .data$group_level == "all") |> + dplyr::filter(.data$variable_name != "Number records" | .data$group_level == "all") |> arrangeSr(estimates) } @@ -115,9 +117,9 @@ summariseObservationPeriod <- function(observationPeriod, dplyr::mutate( "cdm_name" = omopgenerics::cdmName(cdm), "variable_name" = dplyr::case_when( - .data$variable_name == "n" ~ "records per person", - .data$variable_name == "next_obs" ~ "days to next observation period", - .data$variable_name == "duration" ~ "duration in days", + .data$variable_name == "n" ~ "Records per person", + .data$variable_name == "next_obs" ~ "Days to next observation period", + .data$variable_name == "duration" ~ "Duration in days", .default = .data$variable_name ) ) |> @@ -158,14 +160,14 @@ arrangeSr <- function(x, estimates) { group <- c("all", sort(group[group != "all"])) order <- dplyr::tibble( - "variable_name" = c("number records"), + "variable_name" = c("Number records"), "group_level" = "all", "strata_level" = lev, "estimate_name" = "count" ) |> dplyr::union_all( tidyr::expand_grid( - "variable_name" = c("number subjects"), + "variable_name" = c("Number subjects"), "group_level" = group, "strata_level" = lev, "estimate_name" = "count" @@ -191,7 +193,7 @@ arrangeSr <- function(x, estimates) { ) |> dplyr::left_join( dplyr::tibble("variable_name" = c( - "number records", "number subjects", "n", "duration", "next_obs" + "Number records", "Number subjects", "n", "duration", "next_obs" )) |> dplyr::mutate("order_var" = dplyr::row_number()), by = "variable_name" diff --git a/R/summariseRecordCount.R b/R/summariseRecordCount.R index 29a2303..5c95ac7 100644 --- a/R/summariseRecordCount.R +++ b/R/summariseRecordCount.R @@ -112,7 +112,7 @@ summariseRecordCount <- function(cdm, dplyr::mutate( omop_table = .env$table, estimate_name = "count", - variable_name = "incident_counts", + variable_name = "Number records", variable_level = getVariableLevel(.data$additional_level), result_id = 1L, cdm_name = omopgenerics::cdmName(cdm) diff --git a/README.Rmd b/README.Rmd index 807452a..f68aa45 100644 --- a/README.Rmd +++ b/README.Rmd @@ -97,7 +97,7 @@ OmopSketch also provides functions to explore some of (or all) the concepts in t acetaminophen <- c(1125315, 1127433, 1127078) summariseConceptSetCounts(cdm, conceptSet = list("acetaminophen" = acetaminophen)) |> - filter(estimate_name == "record_count") |> + filter(variable_name == "Number records") |> plotConceptSetCounts() ``` diff --git a/man/plotObservationPeriod.Rd b/man/plotObservationPeriod.Rd index 543f468..4cbdf7b 100644 --- a/man/plotObservationPeriod.Rd +++ b/man/plotObservationPeriod.Rd @@ -6,7 +6,7 @@ \usage{ plotObservationPeriod( result, - variableName = "number subjects", + variableName = "Number subjects", plotType = "barplot", facet = NULL, colour = NULL @@ -41,7 +41,7 @@ result <- summariseObservationPeriod(cdm$observation_period) result |> plotObservationPeriod( - variableName = "duration in days", + variableName = "Duration in days", plotType = "boxplot" ) diff --git a/tests/testthat/test-summariseClinicalRecords.R b/tests/testthat/test-summariseClinicalRecords.R index 5b3b4ec..54e510a 100644 --- a/tests/testthat/test-summariseClinicalRecords.R +++ b/tests/testthat/test-summariseClinicalRecords.R @@ -138,12 +138,12 @@ test_that("summariseClinicalRecords() sex and ageGroup argument work", { dplyr::mutate(dplyr::across(dplyr::everything(), as.character)) m_records <- m |> - dplyr::filter(variable_name == "number records", strata_level %in% c("<30", ">= 30"), estimate_name == "count") |> + dplyr::filter(variable_name == "Number records", strata_level %in% c("<30", ">= 30"), estimate_name == "count") |> dplyr::select("age_group" = "strata_level", "estimate_value") |> dplyr::collect() |> dplyr::arrange(age_group) m_subjects <- m |> - dplyr::filter(variable_name == "number subjects", strata_level %in% c("<30", ">= 30"), estimate_name == "count") |> + dplyr::filter(variable_name == "Number subjects", strata_level %in% c("<30", ">= 30"), estimate_name == "count") |> dplyr::select("age_group" = "strata_level", "estimate_value") |> dplyr::collect() |> dplyr::arrange(age_group) @@ -153,7 +153,7 @@ test_that("summariseClinicalRecords() sex and ageGroup argument work", { # Check sex and age group--- x <- summariseClinicalRecords(cdm, "condition_occurrence", sex = TRUE, ageGroup = list(">= 30" = c(30, Inf), "<30" = c(0, 29))) |> - dplyr::filter(variable_name == "number subjects", estimate_name == "count", + dplyr::filter(variable_name == "Number subjects", estimate_name == "count", strata_name == "sex" | strata_name == "overall") |> dplyr::select("strata_name", "strata_level", "estimate_value") |> dplyr::mutate(group = dplyr::if_else(strata_name == "overall",1, 2)) |> @@ -162,7 +162,7 @@ test_that("summariseClinicalRecords() sex and ageGroup argument work", { expect_equal(x$n[[1]], x$n[[2]]) x <- summariseClinicalRecords(cdm, "condition_occurrence", sex = TRUE, ageGroup = list(">= 30" = c(30, Inf), "<30" = c(0, 29))) |> - dplyr::filter(variable_name == "number records", estimate_name == "count", + dplyr::filter(variable_name == "Number records", estimate_name == "count", strata_name == "sex" | strata_name == "overall") |> dplyr::select("strata_name", "strata_level", "estimate_value") |> dplyr::mutate(group = dplyr::if_else(strata_name == "overall",1, 2)) |> @@ -171,7 +171,7 @@ test_that("summariseClinicalRecords() sex and ageGroup argument work", { expect_equal(x$n[[1]], x$n[[2]]) x <- summariseClinicalRecords(cdm, "condition_occurrence", sex = TRUE, ageGroup = list(">= 30" = c(30, Inf), "<30" = c(0, 29))) |> - dplyr::filter(variable_name == "number records", estimate_name == "count", + dplyr::filter(variable_name == "Number records", estimate_name == "count", strata_name == "age_group" | strata_name == "overall") |> dplyr::select("strata_name", "strata_level", "estimate_value") |> dplyr::mutate(group = dplyr::if_else(strata_name == "overall",1, 2)) |> @@ -229,7 +229,7 @@ test_that("summariseClinicalRecords() sex and ageGroup argument work", { # Check num records records <- result |> - dplyr::filter(variable_name == "number records", estimate_name == "count") + dplyr::filter(variable_name == "Number records", estimate_name == "count") expect_identical(records |> dplyr::filter(strata_name == "overall") |> dplyr::pull(estimate_value), "9") expect_identical(records |> dplyr::filter(strata_level == "old") |> dplyr::pull(estimate_value), "5") expect_identical(records |> dplyr::filter(strata_level == "young") |> dplyr::pull(estimate_value), "4") diff --git a/tests/testthat/test-summariseConceptSetCounts.R b/tests/testthat/test-summariseConceptSetCounts.R index 79d144e..e812c31 100644 --- a/tests/testthat/test-summariseConceptSetCounts.R +++ b/tests/testthat/test-summariseConceptSetCounts.R @@ -578,17 +578,17 @@ test_that("interval argument works", { skip_on_cran() # Load mock database ---- cdm <- mockOmopSketch() - expect_no_error(y<-summariseConceptCounts(list(ANTIHISTAMINES= c(21603444)), + expect_no_error(y<-summariseConceptSetCounts(list(ANTIHISTAMINES= c(21603444)), cdm = cdm, interval = "years")) - expect_no_error(o<-summariseConceptCounts(list(ANTIHISTAMINES= c(21603444)), + expect_no_error(o<-summariseConceptSetCounts(list(ANTIHISTAMINES= c(21603444)), cdm = cdm, interval = "overall")) - expect_no_error(q<-summariseConceptCounts(list(ANTIHISTAMINES= c(21603444)), + expect_no_error(q<-summariseConceptSetCounts(list(ANTIHISTAMINES= c(21603444)), cdm = cdm, interval = "quarters")) - expect_no_error(m<-summariseConceptCounts(list(ANTIHISTAMINES= c(21603444)), + expect_no_error(m<-summariseConceptSetCounts(list(ANTIHISTAMINES= c(21603444)), cdm = cdm, interval = "months")) diff --git a/tests/testthat/test-summariseObservationPeriod.R b/tests/testthat/test-summariseObservationPeriod.R index 9869cf6..0ef7e44 100644 --- a/tests/testthat/test-summariseObservationPeriod.R +++ b/tests/testthat/test-summariseObservationPeriod.R @@ -57,16 +57,16 @@ test_that("check summariseObservationPeriod works", { summariseObservationPeriod(estimates = c("mean", "median"))) expect_true(all( resEst |> - dplyr::filter(!.data$variable_name %in% c("number records", "number subjects")) |> + dplyr::filter(!.data$variable_name %in% c("Number records", "Number subjects")) |> dplyr::pull("estimate_name") |> unique() %in% c("mean", "median") )) # counts - expect_identical(resAll$estimate_value[resAll$variable_name == "number records"], "8") + expect_identical(resAll$estimate_value[resAll$variable_name == "Number records"], "8") x <- dplyr::tibble( group_level = c("all", "1st", "2nd", "3rd"), - variable_name = "number subjects", + variable_name = "Number subjects", estimate_value = c("4", "4", "3", "1")) expect_identical(nrow(x), resAll |> dplyr::inner_join(x, by = colnames(x)) |> nrow()) @@ -74,7 +74,7 @@ test_that("check summariseObservationPeriod works", { expect_identical( resAll |> dplyr::filter( - variable_name == "records per person", estimate_name == "mean") |> + variable_name == "Records per person", estimate_name == "mean") |> dplyr::pull("estimate_value"), "2" ) @@ -82,7 +82,7 @@ test_that("check summariseObservationPeriod works", { # duration expect_identical( resAll |> - dplyr::filter(variable_name == "duration in days", estimate_name == "mean") |> + dplyr::filter(variable_name == "Duration in days", estimate_name == "mean") |> dplyr::pull("estimate_value"), as.character(c( mean(c(20, 6, 113, 144, 18, 9, 29, 276)), mean(c(20, 18, 9, 276)), @@ -93,7 +93,7 @@ test_that("check summariseObservationPeriod works", { # days to next observation period expect_identical( resAll |> - dplyr::filter(variable_name == "days to next observation period", estimate_name == "mean") |> + dplyr::filter(variable_name == "Days to next observation period", estimate_name == "mean") |> dplyr::pull("estimate_value"), as.character(c( mean(c(5, 32, 136, 26)), mean(c(5, 32, 136)), 26, NA @@ -102,7 +102,7 @@ test_that("check summariseObservationPeriod works", { # duration - density xx <- resAllD |> - dplyr::filter(variable_name == "duration in days", !is.na(variable_level)) |> + dplyr::filter(variable_name == "Duration in days", !is.na(variable_level)) |> dplyr::group_by(group_level) |> dplyr::summarise( n = dplyr::n(), @@ -116,7 +116,7 @@ test_that("check summariseObservationPeriod works", { # days to next observation period - density xx <- resAll |> - dplyr::filter(variable_name == "days to next observation period", + dplyr::filter(variable_name == "Days to next observation period", !is.na(variable_level)) |> dplyr::group_by(group_level) |> dplyr::summarise( @@ -139,10 +139,10 @@ test_that("check summariseObservationPeriod works", { expect_no_error(resOne <- summariseObservationPeriod(cdm$observation_period)) # counts - expect_identical(resOne$estimate_value[resOne$variable_name == "number records"], "4") + expect_identical(resOne$estimate_value[resOne$variable_name == "Number records"], "4") x <- dplyr::tibble( group_level = c("all", "1st"), - variable_name = "number subjects", + variable_name = "Number subjects", estimate_value = c("4", "4")) expect_identical(nrow(x), resOne |> dplyr::inner_join(x, by = colnames(x)) |> nrow()) @@ -172,97 +172,97 @@ test_that("check summariseObservationPeriod works", { expect_no_error( resAll |> plotObservationPeriod( - variableName = "number subjects", plotType = "barplot") + variableName = "Number subjects", plotType = "barplot") ) expect_error( resAll |> plotObservationPeriod( - variableName = "number subjects", plotType = "boxplot") + variableName = "Number subjects", plotType = "boxplot") ) expect_error( resAll |> plotObservationPeriod( - variableName = "number subjects", plotType = "densityplot") + variableName = "Number subjects", plotType = "densityplot") ) expect_error( resAll |> plotObservationPeriod( - variableName = "number subjects", plotType = "random") + variableName = "Number subjects", plotType = "random") ) expect_error( resAll |> plotObservationPeriod( - variableName = "duration in days", plotType = "barplot") + variableName = "Duration in days", plotType = "barplot") ) expect_no_error( resAll |> plotObservationPeriod( - variableName = "duration in days", plotType = "boxplot") + variableName = "Duration in days", plotType = "boxplot") ) expect_error( resAllN |> plotObservationPeriod( - variableName = "duration in days", plotType = "densityplot") + variableName = "Duration in days", plotType = "densityplot") ) expect_no_error( resAllD |> plotObservationPeriod( - variableName = "duration in days", plotType = "densityplot") + variableName = "Duration in days", plotType = "densityplot") ) expect_error( resAll |> plotObservationPeriod( - variableName = "duration in days", plotType = "random") + variableName = "Duration in days", plotType = "random") ) expect_error( resAll |> plotObservationPeriod( - variableName = "records per person", plotType = "barplot") + variableName = "Records per person", plotType = "barplot") ) expect_no_error( resAll |> plotObservationPeriod( - variableName = "records per person", plotType = "boxplot") + variableName = "Records per person", plotType = "boxplot") ) expect_error( resAllN |> plotObservationPeriod( - variableName = "records per person", plotType = "densityplot") + variableName = "Records per person", plotType = "densityplot") ) expect_no_error( resAllD |> plotObservationPeriod( - variableName = "records per person", plotType = "densityplot") + variableName = "Records per person", plotType = "densityplot") ) expect_error( resAll |> plotObservationPeriod( - variableName = "records per person", plotType = "random") + variableName = "Records per person", plotType = "random") ) expect_error( resAll |> plotObservationPeriod( - variableName = "days to next observation period", plotType = "barplot") + variableName = "Days to next observation period", plotType = "barplot") ) expect_no_error( resAll |> plotObservationPeriod( - variableName = "days to next observation period", plotType = "boxplot") + variableName = "Days to next observation period", plotType = "boxplot") ) expect_error( resAllN |> plotObservationPeriod( - variableName = "days to next observation period", plotType = "densityplot") + variableName = "Days to next observation period", plotType = "densityplot") ) expect_no_error( resAllD |> plotObservationPeriod( - variableName = "days to next observation period", plotType = "densityplot") + variableName = "Days to next observation period", plotType = "densityplot") ) expect_error( resAll |> plotObservationPeriod( - variableName = "days to next observation period", plotType = "random") + variableName = "Days to next observation period", plotType = "random") ) PatientProfiles::mockDisconnect(cdm = cdm) @@ -275,10 +275,10 @@ test_that("check it works with mockOmopSketch", { sop <- summariseObservationPeriod(cdm$observation_period) # counts - expect_identical(sop$estimate_value[sop$variable_name == "number records"], "5") + expect_identical(sop$estimate_value[sop$variable_name == "Number records"], "5") x <- dplyr::tibble( strata_level = c("overall", "1st"), - variable_name = "number subjects", + variable_name = "Number subjects", estimate_value = c("5","5")) expect_identical(nrow(x), sop |> dplyr::inner_join(x, by = colnames(x)) |> nrow()) @@ -286,7 +286,7 @@ test_that("check it works with mockOmopSketch", { expect_identical( sop |> dplyr::filter( - variable_name == "records per person", estimate_name != "sd", !grepl("density", estimate_name)) |> + variable_name == "Records per person", estimate_name != "sd", !grepl("density", estimate_name)) |> dplyr::pull("estimate_value"), c(rep("1",8)) ) @@ -294,7 +294,7 @@ test_that("check it works with mockOmopSketch", { # duration expect_identical( sop |> - dplyr::filter(variable_name == "duration in days", estimate_name %in% c("min","q25","median","q75","max")) |> + dplyr::filter(variable_name == "Duration in days", estimate_name %in% c("min","q25","median","q75","max")) |> dplyr::pull("estimate_value") |> unique() |> sort(), @@ -310,7 +310,7 @@ test_that("check it works with mockOmopSketch", { # days to next observation period expect_identical( sop |> - dplyr::filter(variable_name == "days to next observation period")|>nrow(), 0L + dplyr::filter(variable_name == "Days to next observation period")|>nrow(), 0L ) # Check result type @@ -389,14 +389,14 @@ test_that("check summariseObservationPeriod strata works", { # check strata groups have the expected value expect_identical(resStrata |> - dplyr::filter(variable_name == "number subjects", + dplyr::filter(variable_name == "Number subjects", strata_level == "Female", group_level == "2nd") |> dplyr::pull("estimate_value"),"2") expect_identical(resStrata |> omopgenerics::splitStrata() |> - dplyr::filter(variable_name == "number subjects", + dplyr::filter(variable_name == "Number subjects", sex == "Male", age_group == ">=10", group_level == "3rd") |> @@ -405,7 +405,7 @@ test_that("check summariseObservationPeriod strata works", { # duration expect_identical( resStrata |> - dplyr::filter(variable_name == "duration in days", estimate_name == "mean", strata_level == ">=10") |> + dplyr::filter(variable_name == "Duration in days", estimate_name == "mean", strata_level == ">=10") |> dplyr::pull("estimate_value"), as.character(c( mean(c(20, 18, 6, 144, 113)), @@ -416,7 +416,7 @@ test_that("check summariseObservationPeriod strata works", { expect_identical( resStrata |> - dplyr::filter(variable_name == "duration in days", estimate_name == "mean", strata_level == "<10") |> + dplyr::filter(variable_name == "Duration in days", estimate_name == "mean", strata_level == "<10") |> dplyr::pull("estimate_value"), as.character(c( mean(c(9, 276, 29)), @@ -428,7 +428,7 @@ test_that("check summariseObservationPeriod strata works", { expect_identical( resStrata |> omopgenerics::splitStrata() |> - dplyr::filter(variable_name == "days to next observation period", estimate_name == "mean", + dplyr::filter(variable_name == "Days to next observation period", estimate_name == "mean", sex == "Female", age_group == "<10", group_level == "1st") |> dplyr::pull("estimate_value"), "32" ) @@ -437,28 +437,28 @@ test_that("check summariseObservationPeriod strata works", { expect_no_error( x |> plotObservationPeriod( - variableName = "duration in days", plotType = "densityplot", colour = "sex", facet = "age_group") + variableName = "Duration in days", plotType = "densityplot", colour = "sex", facet = "age_group") ) expect_no_error( x |> plotObservationPeriod( - variableName = "days to next observation period", plotType = "densityplot", colour = "sex", facet = "age_group") + variableName = "Days to next observation period", plotType = "densityplot", colour = "sex", facet = "age_group") ) expect_no_error( x |> plotObservationPeriod( - variableName = "records per person", plotType = "densityplot", colour = "sex", facet = "age_group") + variableName = "Records per person", plotType = "densityplot", colour = "sex", facet = "age_group") ) expect_error(x |> plotObservationPeriod( - variableName = "number records", plotType = "densityplot", colour = "sex", facet = "age_group")) + variableName = "Number records", plotType = "densityplot", colour = "sex", facet = "age_group")) y<-summariseObservationPeriod(cdm$observation_period, estimates = "mean", sex = TRUE, ageGroup = list(c(0,9), c(10, Inf))) expect_error( y |> plotObservationPeriod( - variableName = "records per person", plotType = "densityplot", colour = "sex", facet = "age_group") + variableName = "Records per person", plotType = "densityplot", colour = "sex", facet = "age_group") ) PatientProfiles::mockDisconnect(cdm = cdm)