darwin-eu / omopgenerics

https://darwin-eu.github.io/omopgenerics/
Apache License 2.0
2 stars 1 forks source link

uninformative error if exporting results with different min cell count suppression #535

Closed edward-burn closed 2 weeks ago

edward-burn commented 4 weeks ago

Currenly suppress (which is used in export) is expecting the summarised result to have a single min cell count used https://github.com/darwin-eu-dev/omopgenerics/blob/555df1631fd22090627de87a0244427734b64d23/R/methodSuppress.R#L84 causing an uninformative error if more than one is used

library(omopgenerics)
#> 
#> Attaching package: 'omopgenerics'
#> The following object is masked from 'package:stats':
#> 
#>     filter
x <- dplyr::tibble(
  "result_id" = as.integer(1),
  "cdm_name" = "mock",
  "group_name" = "overall",
  "group_level" = "overall",
  "strata_name" = c(rep("overall", 6), rep("sex", 3)),
  "strata_level" = c(rep("overall", 6), "male", "female", "female"),
  "variable_name" = c("number records", "age_group", "age_group", "age_group", "age_group", "my_variable", "number records", "age_group", "age_group"),
  "variable_level" = c(NA, "<50", "<50", ">=50", ">=50", NA, NA, "<50", "<50"),
  "estimate_name" = c("count", "count", "percentage", "count", "percentage", "random", "count", "count", "percentage"),
  "estimate_type" = c("integer", "integer", "percentage", "integer", "percentage", "numeric", "integer", "integer", "percentage"),
  "estimate_value" = c("10", "5", "50", "3", "30", "1", "3", "12", "6"),
  "additional_name" = "overall",
  "additional_level" = "overall"
)

a <- newSummarisedResult(
  x,
  settings = dplyr::tibble(
    "result_id" = as.integer(1),
    "result_type" = "summarised_characteristics",
    "package_name" = "omopgenerics",
    "package_version" = as.character(utils::packageVersion("omopgenerics")))) |> 
  suppress(5)
b <- newSummarisedResult(
  x,
  settings = dplyr::tibble(
    "result_id" = as.integer(1),
    "result_type" = "summarised_characteristics",
    "package_name" = "omopgenerics",
    "package_version" = as.character(utils::packageVersion("omopgenerics")))) |> 
  suppress(10)

result <- bind(a, b)
exportSummarisedResult(result)
#> Error in if (prevSupp > minCellCount) {: the condition has length > 1

Created on 2024-10-08 with reprex v2.0.2

catalamarti commented 2 weeks ago

538