Skip to content

Commit

Permalink
Cleanup dependencies and fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
galachad committed Jul 23, 2024
1 parent 2cc2a43 commit c98acb3
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 65 deletions.
21 changes: 10 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,15 @@ Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Depends: R (>= 4.2)
Imports:
admiraldev,
admiraldev (>= 1.1.0),
dplyr (>= 1.0.0),
memoise,
assertthat,
purrr (>= 0.3.3),
rlang (>= 0.4.4),
purrr (>= 1.0.1),
rlang (>= 1.0.2),
tibble (>= 3.2.0),
vctrs (>= 0.5.0),
stringr (>= 1.4.0),
tibble,
vctrs,
readr,
glue,
DT,
memoise (>= 2.0.1),
assertthat,
pillar
Suggests:
knitr,
Expand All @@ -56,7 +53,9 @@ Suggests:
magrittr,
rmarkdown,
spelling,
testthat (>= 3.1.7)
testthat (>= 3.1.7),
DT,
readr
VignetteBuilder: knitr
Config/testthat/edition: 3
Config/testthat/parallel: true
6 changes: 1 addition & 5 deletions R/assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ assert_logical_vector <- function(arg, optional = FALSE) {
}

if (!is.logical(arg)) {
err_msg <- sprintf(
"`arg` must be a logical vector but is %s.",
admiraldev::what_is_it(arg)
)
rlang::abort(err_msg)
cli::cli_abort('`arg` must be a logical vector but is {.obj_type_friendly {arg}}')
}

invisible(arg)
Expand Down
9 changes: 5 additions & 4 deletions R/ct.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ assert_ct_spec <- function(ct_spec, optional = FALSE) {
}

if (!is.null(ct_spec) && anyNA(ct_spec[[ct_spec_vars("ct_clst")]])) {
rlang::abort(glue::glue("`{ct_spec_vars('ct_clst')}` can't have any NA values."))
rlang::abort(stringr::str_glue("`{ct_spec_vars('ct_clst')}` can't have any NA values."))
}

if (!is.null(ct_spec) && anyNA(ct_spec[[ct_spec_vars("to")]])) {
rlang::abort(glue::glue("`{ct_spec_vars('to')}` can't have any NA values."))
rlang::abort(stringr::str_glue("`{ct_spec_vars('to')}` can't have any NA values."))
}

invisible(ct_spec)
Expand Down Expand Up @@ -340,7 +340,8 @@ ct_map <-
#'
#' @export
read_ct_spec <- function(file = stop("`file` must be specified")) {
ct_spec <- readr::read_csv(file = file, col_types = "c")
ct_spec <- read.csv(file = file, na.strings = c("NA", ""), colClasses = "character") |>
tibble::as_tibble()
assert_ct_spec(ct_spec)

ct_spec
Expand Down Expand Up @@ -388,7 +389,7 @@ ct_spec_example <- function(example) {

if (identical(local_path, "")) {
stop(
glue::glue(
stringr::str_glue(
"'{example}' does not match any ct spec files. Run `ct_spec_example()` for options."
),
call. = FALSE
Expand Down
2 changes: 2 additions & 0 deletions R/derive_blfl.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ dtc_datepart <- function(dtc, partial_as_na = TRUE) {
#' @export
#'
#' @keywords internal
#'
#' @examples
#' ## Partial or missing times set to NA and seconds ignored by default
#' sdtm.oak:::dtc_timepart(
#' c(NA, "", "2021-12-25", "2021-12-25T12", "2021-12-25T12:30", "2021-12-25T12:30:59")
Expand Down
7 changes: 5 additions & 2 deletions R/domain_example.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ domain_example <- function(example) {

if (identical(local_path, "")) {
stop(
glue::glue(
stringr::str_glue(
"'{example}' does not match any domain example files. Run `domain_example()` for options."
),
call. = FALSE
Expand Down Expand Up @@ -125,5 +125,8 @@ read_domain_example <- function(example) {
}

path <- domain_example(example)
readr::read_rds(file = path)
con <- file(path)
on.exit(close(con))

readRDS(con)
}
72 changes: 29 additions & 43 deletions man/dtc_timepart.Rd

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

0 comments on commit c98acb3

Please sign in to comment.