Skip to content

Commit

Permalink
checks for missing soc and ae in complete_ae_data (#212)
Browse files Browse the repository at this point in the history
* add more errors and message along with corresponding tests

* tweaks from DS suggestions

* bump gt version

* update roxygen version

* update snapshot texts for style_xxx

* Increment version number to 0.3.0
  • Loading branch information
shannonpileggi authored Nov 17, 2023
1 parent be9d3bf commit d59e805
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 965 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: gtreg
Title: Regulatory Tables for Clinical Research
Version: 0.2.0.9001
Version: 0.3.0
Authors@R: c(
person("Shannon", "Pileggi", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0002-7732-4164")),
Expand Down Expand Up @@ -32,7 +32,7 @@ Imports:
tidyr (>= 1.2.1)
Suggests:
covr (>= 3.6.1),
gt (>= 0.9.0),
gt (>= 0.10.0),
knitr (>= 1.43),
rmarkdown (>= 2.22),
spelling (>= 2.2.1),
Expand All @@ -44,4 +44,4 @@ Encoding: UTF-8
Language: en-US
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# gtreg (development version)
# gtreg 0.3.0

* Add errors for missing `soc` and `ae` in `complete_ae_data()` (#204).

* Fix GitHub link on `pkgdown` site (#207).

Expand Down
13 changes: 13 additions & 0 deletions R/complete_ae_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,24 @@
by = c(id, strata))) > 0) {
stop("There are `id=`/`strata=` combinations in `data=` not found in `id_df=`.", call. = FALSE)
}

# check for missing soc
if (!is.null(soc) && any(is.na(data[soc]))) {
stop("At least one `soc` is missing.", call. = FALSE)
}

# check for missing ae
if (!is.null(ae) && any(is.na(data[ae]))) {
stop("At least one `ae` is missing.", call. = FALSE)
}

# check for an ae listed under more than one soc
if (!is.null(soc) &&
nrow(dplyr::distinct(data[c(ae, soc)])) != nrow(dplyr::distinct(data[ae]))) {
stop("The `ae` levels must be unique across all `soc` levels.", call. = FALSE)
}


# some default factor levels -------------------------------------------------
initial_missing <- missing_text
initial_dummy <- "NOT OBSERVED"
Expand Down
Loading

0 comments on commit d59e805

Please sign in to comment.