Skip to content

Commit

Permalink
Closes #434 remove pharmaversesdtm dependency (#439)
Browse files Browse the repository at this point in the history
* 434 remove pharmaversesdtm dependency

* 434 update STYLER

* 434 update NEWS file

* 434 do not use TIBBLE

* 434 remove remaining TIBBLE

---------

Co-authored-by: Ben Straub <[email protected]>
  • Loading branch information
millerg23 and bms63 authored Apr 19, 2024
1 parent 9f8b3a8 commit f0c7509
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 36 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ Suggests:
htmltools,
knitr,
methods,
pharmaversesdtm,
miniUI,
pkgdown,
rmarkdown,
rstudioapi,
spelling,
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions R/assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 10 additions & 4 deletions R/tmp_vars.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 6 additions & 2 deletions R/warnings.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 5 additions & 2 deletions man/assert_filter_cond.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions man/assert_symbol.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions man/get_new_tmp_var.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions man/remove_tmp_vars.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions man/warn_if_vars_exist.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
65 changes: 56 additions & 9 deletions tests/testthat/test-assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
})
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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))
)
})

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-tmp_vars.R
Original file line number Diff line number Diff line change
@@ -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 ----
Expand Down
6 changes: 5 additions & 1 deletion tests/testthat/test-warnings.R
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
8 changes: 7 additions & 1 deletion vignettes/writing_vignettes.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit f0c7509

Please sign in to comment.