From be0096c2237b9621d8b4f8abd84c5a62bccfca58 Mon Sep 17 00:00:00 2001 From: Malte Londschien Date: Tue, 8 Aug 2023 09:44:51 +0200 Subject: [PATCH] Allow levels to be missing for fct_concept. --- R/concept-load.R | 2 ++ R/concept-utils.R | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/R/concept-load.R b/R/concept-load.R index a420f1bf..e5f85d1c 100644 --- a/R/concept-load.R +++ b/R/concept-load.R @@ -491,6 +491,8 @@ load_concepts.fct_cncpt <- function(x, aggregate = NULL, ..., res <- set(res, j = "val_var", value = character()) } else if (is.character(lvl)) { keep <- res[["val_var"]] %chin% lvl + } else if (is.null(lvl)) { + keep <- TRUE } else { keep <- res[["val_var"]] %in% lvl } diff --git a/R/concept-utils.R b/R/concept-utils.R index 114bd1ea..96d8f3f6 100644 --- a/R/concept-utils.R +++ b/R/concept-utils.R @@ -1007,11 +1007,11 @@ init_cncpt.unt_cncpt <- function(x, unit = NULL, min = NULL, max = NULL, ...) { #' #' @rdname data_concepts #' @export -init_cncpt.fct_cncpt <- function(x, levels, ...) { +init_cncpt.fct_cncpt <- function(x, levels = NULL, ...) { warn_dots(...) - assert_that(is.atomic(levels), has_length(levels), + assert_that(null_or(levels, is.atomic), null_or(levels, has_length), null_or(x[["aggregate"]], is.string)) x[["levels"]] <- levels