Skip to content

Commit

Permalink
Throw an error if a group level is called "Total", "Variable", "p", "…
Browse files Browse the repository at this point in the history
…test_name", "CI", or "CI_name".
  • Loading branch information
jan-imbi committed Dec 15, 2023
1 parent 0506d82 commit 6b7e5a5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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="[email protected]", 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")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
7 changes: 7 additions & 0 deletions R/descr.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand Down

0 comments on commit 6b7e5a5

Please sign in to comment.