From 6b7e5a5194f4da1537d6555f929eddb36fcdb079 Mon Sep 17 00:00:00 2001 From: Jan Meis Date: Fri, 15 Dec 2023 08:45:02 +0100 Subject: [PATCH] Throw an error if a group level is called "Total", "Variable", "p", "test_name", "CI", or "CI_name". --- DESCRIPTION | 4 ++-- NEWS.md | 4 ++++ R/descr.R | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 32b916e..95d0c8a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: DescrTab2 Type: Package Title: Publication Quality Descriptive Statistics Tables -Version: 2.1.24 -Date: 2023-11-22 +Version: 2.1.25 +Date: 2023-12-15 Authors@R: c(person("Jan", "Meis", role = c("aut", "cre"), email="meis@imbi.uni-heidelberg.de", comment = c(ORCID = "0000-0001-5407-7220")), person("Lukas", "Baumann", role = c("aut"), comment = c(ORCID = "0000-0001-7931-7470")), person("Maximilian", "Pilz", role = c("aut"), comment = c(ORCID = "0000-0002-9685-1613")), diff --git a/NEWS.md b/NEWS.md index e4c02f9..6eb53b5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# Version 2.1.25 + +* Throw an error if a group level is called "Total", "Variable", "p", "test_name", "CI", or "CI_name". + # Version 2.1.24 * Change default for print_CI to false. diff --git a/R/descr.R b/R/descr.R index 0bafacf..0c0a6e2 100644 --- a/R/descr.R +++ b/R/descr.R @@ -401,6 +401,9 @@ descr <- group_levels <- levels(group_var) names(group_levels) <- group_levels + if (any(c("Total", "Variable", "p", "test_name", "CI", "CI_name") %in% group_levels)) { + stop("Your group variable may not contain the levels named 'Total', 'Variable', 'p', 'test_name', 'CI', or 'CI_name'. Please rename the levels in your group variable.") + } } else { group_var <- NULL group_levels <- NULL @@ -441,6 +444,10 @@ descr <- ## If options lists were passed as named named vectors, coerce to list group_labels %<>% as.list() + if (any(c("Total", "Variable", "p", "test_name", "CI", "CI_name") %in% group_labels)) { + stop("Your group labels may not contain the names 'Total', 'Variable', 'p', 'test_name', 'CI', or 'CI_name'. Please rename the levels in your group variable.") + } + var_options <- lapply(var_options, as.list)