diff --git a/DESCRIPTION b/DESCRIPTION index 2bad25bc..651fe383 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,7 +48,8 @@ Suggests: htmltools, knitr, methods, - pharmaversesdtm, + miniUI, + pkgdown, rmarkdown, rstudioapi, spelling, diff --git a/NEWS.md b/NEWS.md index 7ab4a4b0..57e440f2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,7 @@ * No longer exporting `is_named()` function. (#401) +* `pharmaversesdtm` removed as a dependency. (#434) * As a part of the error messaging update, the following changes were made. - The `assert_s3_class(class)` argument has been renamed to `assert_s3_class(cls)`. (#367) diff --git a/R/assertions.R b/R/assertions.R index 61e347f6..69d4f6d6 100644 --- a/R/assertions.R +++ b/R/assertions.R @@ -374,11 +374,13 @@ assert_logical_scalar <- function(arg, optional = FALSE, #' @keywords assertion #' @family assertion #' @examples -#' library(pharmaversesdtm) #' library(dplyr, warn.conflicts = FALSE) #' library(rlang) -#' data(dm) -#' +#' dm <- dplyr::tribble( +#' ~DOMAIN, ~USUBJID, +#' "DM", "01-701-1015", +#' "DM", "01-701-1016", +#' ) #' example_fun <- function(dat, var) { #' var <- assert_symbol(enexpr(var)) #' select(dat, !!var) @@ -486,10 +488,13 @@ assert_expr <- function(arg, #' @family assertion #' #' @examples -#' library(pharmaversesdtm) #' library(dplyr, warn.conflicts = FALSE) #' library(rlang) -#' data(dm) +#' dm <- dplyr::tribble( +#' ~DOMAIN, ~STUDYID, ~USUBJID, ~AGE, +#' "DM", "STUDY X", "01-701-1015", 64, +#' "DM", "STUDY X", "01-701-1016", 65, +#' ) #' #' # typical usage in a function as an argument check #' example_fun <- function(dat, x) { diff --git a/R/tmp_vars.R b/R/tmp_vars.R index 5dc20ca4..81e863d9 100644 --- a/R/tmp_vars.R +++ b/R/tmp_vars.R @@ -19,8 +19,11 @@ #' #' @examples #' library(dplyr, warn.conflicts = FALSE) -#' library(pharmaversesdtm) -#' data(dm) +#' dm <- tribble( +#' ~DOMAIN, ~STUDYID, ~USUBJID, +#' "DM", "STUDY X", "01-701-1015", +#' "DM", "STUDY X", "01-701-1016", +#' ) #' #' tmp_var <- get_new_tmp_var(dm) #' mutate(dm, !!tmp_var := NA) @@ -69,8 +72,11 @@ get_new_tmp_var <- function(dataset, prefix = "tmp_var") { #' #' @examples #' library(dplyr, warn.conflicts = FALSE) -#' library(pharmaversesdtm) -#' data(dm) +#' dm <- tribble( +#' ~DOMAIN, ~STUDYID, ~USUBJID, +#' "DM", "STUDY X", "01-701-1015", +#' "DM", "STUDY X", "01-701-1016", +#' ) #' dm <- select(dm, USUBJID) #' tmp_var <- get_new_tmp_var(dm) #' dm <- mutate(dm, !!tmp_var := NA) diff --git a/R/warnings.R b/R/warnings.R index d0250bc7..4590e0c3 100644 --- a/R/warnings.R +++ b/R/warnings.R @@ -14,8 +14,12 @@ #' @export #' #' @examples -#' library(pharmaversesdtm) -#' data(dm) +#' library(dplyr, warn.conflicts = FALSE) +#' dm <- tribble( +#' ~USUBJID, ~ARM, +#' "01-701-1015", "Placebo", +#' "01-701-1016", "Placebo", +#' ) #' #' ## No warning as `AAGE` doesn't exist in `dm` #' warn_if_vars_exist(dm, "AAGE") diff --git a/man/assert_filter_cond.Rd b/man/assert_filter_cond.Rd index 75cbe8ce..173f7400 100644 --- a/man/assert_filter_cond.Rd +++ b/man/assert_filter_cond.Rd @@ -52,10 +52,13 @@ Check if \code{arg} is a suitable filtering condition to be used in functions like \code{subset} or \code{dplyr::filter}. } \examples{ -library(pharmaversesdtm) library(dplyr, warn.conflicts = FALSE) library(rlang) -data(dm) +dm <- dplyr::tribble( + ~DOMAIN, ~STUDYID, ~USUBJID, ~AGE, + "DM", "STUDY X", "01-701-1015", 64, + "DM", "STUDY X", "01-701-1016", 65, +) # typical usage in a function as an argument check example_fun <- function(dat, x) { diff --git a/man/assert_symbol.Rd b/man/assert_symbol.Rd index a6da4a10..7ceeaaf9 100644 --- a/man/assert_symbol.Rd +++ b/man/assert_symbol.Rd @@ -49,11 +49,13 @@ invisibly otherwise. Checks if an argument is a symbol } \examples{ -library(pharmaversesdtm) library(dplyr, warn.conflicts = FALSE) library(rlang) -data(dm) - +dm <- dplyr::tribble( + ~DOMAIN, ~USUBJID, + "DM", "01-701-1015", + "DM", "01-701-1016", +) example_fun <- function(dat, var) { var <- assert_symbol(enexpr(var)) select(dat, !!var) diff --git a/man/get_new_tmp_var.Rd b/man/get_new_tmp_var.Rd index e0a5e799..2de03453 100644 --- a/man/get_new_tmp_var.Rd +++ b/man/get_new_tmp_var.Rd @@ -26,8 +26,11 @@ The function returns a new unique temporary variable name to be used inside } \examples{ library(dplyr, warn.conflicts = FALSE) -library(pharmaversesdtm) -data(dm) +dm <- tribble( + ~DOMAIN, ~STUDYID, ~USUBJID, + "DM", "STUDY X", "01-701-1015", + "DM", "STUDY X", "01-701-1016", +) tmp_var <- get_new_tmp_var(dm) mutate(dm, !!tmp_var := NA) diff --git a/man/remove_tmp_vars.Rd b/man/remove_tmp_vars.Rd index 339fdb1e..a19e772b 100644 --- a/man/remove_tmp_vars.Rd +++ b/man/remove_tmp_vars.Rd @@ -17,8 +17,11 @@ Remove All Temporary Variables Created Within the Current Function Environment } \examples{ library(dplyr, warn.conflicts = FALSE) -library(pharmaversesdtm) -data(dm) +dm <- tribble( + ~DOMAIN, ~STUDYID, ~USUBJID, + "DM", "STUDY X", "01-701-1015", + "DM", "STUDY X", "01-701-1016", +) dm <- select(dm, USUBJID) tmp_var <- get_new_tmp_var(dm) dm <- mutate(dm, !!tmp_var := NA) diff --git a/man/warn_if_vars_exist.Rd b/man/warn_if_vars_exist.Rd index 2c5ca4a6..043bc817 100644 --- a/man/warn_if_vars_exist.Rd +++ b/man/warn_if_vars_exist.Rd @@ -18,8 +18,12 @@ No return value, called for side effects Warn if a variable already exists inside a dataset } \examples{ -library(pharmaversesdtm) -data(dm) +library(dplyr, warn.conflicts = FALSE) +dm <- tribble( + ~USUBJID, ~ARM, + "01-701-1015", "Placebo", + "01-701-1016", "Placebo", +) ## No warning as `AAGE` doesn't exist in `dm` warn_if_vars_exist(dm, "AAGE") diff --git a/tests/testthat/_snaps/assertions.md b/tests/testthat/_snaps/assertions.md index f9150a7e..77e98852 100644 --- a/tests/testthat/_snaps/assertions.md +++ b/tests/testthat/_snaps/assertions.md @@ -264,7 +264,7 @@ # assert_one_to_one Test 84: error if there is a one to many mapping Code - assert_one_to_one(pharmaversesdtm::dm, exprs(DOMAIN), exprs(USUBJID)) + assert_one_to_one(dm, exprs(DOMAIN), exprs(USUBJID)) Condition Error: ! For some values of "DOMAIN" there is more than one value of "USUBJID" diff --git a/tests/testthat/test-assertions.R b/tests/testthat/test-assertions.R index b9063e79..df46aedf 100644 --- a/tests/testthat/test-assertions.R +++ b/tests/testthat/test-assertions.R @@ -6,13 +6,21 @@ test_that("assert_has_variables Test 1: error if a required variable is missing "1" ) + dm <- dplyr::tribble( + ~DOMAIN, ~USUBJID, + "DM", "01-701-1015", + "DM", "01-701-1016", + "DM", "01-701-1023", + "DM", "01-701-1024", + ) + expect_error( assert_has_variables(data, "TRT01P"), class = "lifecycle_error_deprecated" ) expect_error( - assert_has_variables(pharmaversesdtm::dm, c("TRT01P", "AVAL")), + assert_has_variables(dm, c("TRT01P", "AVAL")), class = "lifecycle_error_deprecated" ) }) @@ -293,7 +301,11 @@ test_that("assert_data_frame Test 15: error if required variables are missing", assert_data_frame(dataset, required_vars = exprs(STUDYID, USUBJID)) } - admiral_dm <- pharmaversesdtm::dm %>% select(-c(STUDYID, USUBJID)) + admiral_dm <- dplyr::tribble( + ~USUBJID2, + "01-701-1015", + "01-701-1016", + ) expect_error( example_fun(admiral_dm) @@ -306,7 +318,11 @@ test_that("assert_data_frame Test 16: error if required variable is missing", { assert_data_frame(dataset, required_vars = exprs(STUDYID, USUBJID)) } - admiral_dm <- pharmaversesdtm::dm %>% select(-c(USUBJID)) + admiral_dm <- dplyr::tribble( + ~USUBJID, + "01-701-1015", + "01-701-1016", + ) expect_error( example_fun(admiral_dm) @@ -533,7 +549,11 @@ test_that("assert_symbol Test 28: `assert_symbol` does not throw an error if `ar v <- enexpr(var) } - admiral_dm <- pharmaversesdtm::dm + admiral_dm <- dplyr::tribble( + ~DOMAIN, ~USUBJID, + "DM", "01-701-1015", + "DM", "01-701-1016", + ) example_fun <- function(arg) { assert_symbol(arg) @@ -549,8 +569,14 @@ test_that("assert_symbol Test 28: `assert_symbol` does not throw an error if `ar # assert_expr ---- ## Test 29: `assert_expr` does not throw an error if `arg` is an expression ---- test_that("assert_expr Test 29: `assert_expr` does not throw an error if `arg` is an expression", { + dm <- dplyr::tribble( + ~DOMAIN, ~USUBJID, + "DM", "01-701-1015", + "DM", "01-701-1016", + ) + expect_invisible( - assert_expr(var <- expr(pharmaversesdtm::dm)) + assert_expr(var <- expr(dm)) ) }) @@ -873,8 +899,13 @@ test_that("assert_named_exprs Test 54: error if `arg` is not a named list of exp example_fun(5), class = "lifecycle_error_deprecated" ) + dm <- dplyr::tribble( + ~DOMAIN, ~USUBJID, + "DM", "01-701-1015", + "DM", "01-701-1016", + ) expect_error( - example_fun(pharmaversesdtm::dm), + example_fun(dm), class = "lifecycle_error_deprecated" ) expect_error( @@ -1267,23 +1298,39 @@ test_that("assert_list_element Test 83: error if the elements do not fulfill the # assert_one_to_one ---- ## Test 84: error if there is a one to many mapping ---- test_that("assert_one_to_one Test 84: error if there is a one to many mapping", { + dm <- dplyr::tribble( + ~DOMAIN, ~USUBJID, + "DM", "01-701-1015", + "DM", "01-701-1016", + "DM", "01-701-1023", + "DM", "01-701-1024", + ) + expect_error( - assert_one_to_one(pharmaversesdtm::dm, exprs(DOMAIN), exprs(USUBJID)), + assert_one_to_one(dm, exprs(DOMAIN), exprs(USUBJID)), class = "assert_one_to_one" ) admiraldev_environment$one_to_many <- NULL expect_snapshot( error = TRUE, - assert_one_to_one(pharmaversesdtm::dm, exprs(DOMAIN), exprs(USUBJID)) + assert_one_to_one(dm, exprs(DOMAIN), exprs(USUBJID)) ) admiraldev_environment$one_to_many <- NULL }) ## Test 85: error if there is a many to one mapping ---- test_that("assert_one_to_one Test 85: error if there is a many to one mapping", { + dm <- dplyr::tribble( + ~DOMAIN, ~USUBJID, + "DM", "01-701-1015", + "DM", "01-701-1016", + "DM", "01-701-1023", + "DM", "01-701-1024", + ) + expect_error( - assert_one_to_one(pharmaversesdtm::dm, exprs(USUBJID), exprs(DOMAIN)), + assert_one_to_one(dm, exprs(USUBJID), exprs(DOMAIN)), class = "assert_one_to_one" ) admiraldev_environment$many_to_one <- NULL diff --git a/tests/testthat/test-tmp_vars.R b/tests/testthat/test-tmp_vars.R index eae38569..c4ae2b9b 100644 --- a/tests/testthat/test-tmp_vars.R +++ b/tests/testthat/test-tmp_vars.R @@ -1,4 +1,8 @@ -dm <- select(pharmaversesdtm::dm, USUBJID) +dm <- dplyr::tribble( + ~USUBJID, + "01-701-1015", + "01-701-1016", +) # get_new_tmp_var ---- ## Test 1: creating temporary variables works ---- diff --git a/tests/testthat/test-warnings.R b/tests/testthat/test-warnings.R index 204110fb..c46ef3f1 100644 --- a/tests/testthat/test-warnings.R +++ b/tests/testthat/test-warnings.R @@ -1,7 +1,11 @@ # warn_if_vars_exist ---- ## Test 1: warning if a variable already exists in the input dataset ---- test_that("warn_if_vars_exist Test 1: warning if a variable already exists in the input dataset", { - dm <- pharmaversesdtm::dm + dm <- dplyr::tribble( + ~USUBJID, ~AGE, ~AGEU, ~ARM, + "01-701-1015", 25, "YEARS", "Placebo", + "01-701-1016", 27, "YEARS", "Placebo", + ) expect_snapshot( warn_if_vars_exist(dm, "AGE") diff --git a/vignettes/writing_vignettes.Rmd b/vignettes/writing_vignettes.Rmd index 29375125..6bd32619 100644 --- a/vignettes/writing_vignettes.Rmd +++ b/vignettes/writing_vignettes.Rmd @@ -127,10 +127,16 @@ function so that it is displayed consistently across the vignettes.E.g. ```{r, include=FALSE} library(lubridate) library(dplyr) -library(pharmaversesdtm) library(DT) data(vs) +vs <- tribble( + ~USUBJID, ~VSTESTCD, ~VISIT, ~VSDTC, + "01-701-1015", "WEIGHT", "BASELINE", "2013-12-26", + "01-701-1015", "WEIGHT", "WEEK 2", "2014-01-14", + "01-701-1016", "WEIGHT", "BASELINE", "2014-01-06", + "01-701-1016", "WEIGHT", "WEEK 2", "2014-01-22", +) ``` ```{r, eval=FALSE, echo=TRUE}