Skip to content

Commit

Permalink
Merge branch 'main' into 2484-general-issue-chg-and-pchg-populated-fo…
Browse files Browse the repository at this point in the history
…r-baseline-and-pre-baseline-records-in-the-templates
  • Loading branch information
steventing12 authored Sep 3, 2024
2 parents 6e1f83e + eea45a6 commit d4ec9ee
Show file tree
Hide file tree
Showing 27 changed files with 47 additions and 845 deletions.
1 change: 1 addition & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ https://packagemanager.rstudio.com/cran/__linux__/focal/latest
https://raw.githubusercontent.com/pharmaverse/admiral/main/inst/cheatsheet/cheatsheet_image.png
https://rsc.niaid.nih.gov/clinical-research-sites/daids-adverse-event-grading-tables
https://rsc.niaid.nih.gov/sites/default/files/daidsgradingcorrectedv21.pdf
https://www.fda.gov/media/116737/download
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: admiral
Title: ADaM in R Asset Library
Version: 1.1.1.9006
Version: 1.1.1.9007
Authors@R: c(
person("Ben", "Straub", , "[email protected]", role = c("aut", "cre")),
person("Stefan", "Bundfuss", role = "aut",
Expand Down
22 changes: 22 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@
## Updates of Existing Functions

## Breaking Changes

- The following function arguments are entering the next phase of the deprecation process: (#2487)

### Phase 1 (warning)

### Phase 2 (error)

### Phase 3 (removed)
- `consolidate_metadata(check_keys)`
- Removed at v1.1.1 `compute_egfr(wt)`
- Removed at v1.1.1 `derive_expected_records(dataset_expected_obs)`
- Removed at v1.1.1 `derive_locf_records(dataset_expected_obs)`
- `derive_extreme_event(ignore_event_order)`
- `derive_vars_merged(match_flag)`
- `derive_var_merged_summary(new_var, analysis_var, summary_fun)`
- Removed at v1.1.1 `derive_param_computed(analysis_value, analysis_var)`
- `derive_param_exposure(filter, analysis_var, summary_fun)`
- `derive_summary_records(filter)`
- Removed at v1.1.1 `derive_extreme_records(filter)`
- `derive_var_joined_exist_flag(first_cond, filter)`
- `event_joined(first_cond)`
- `filter_joined(first_cond, filter)`

## Documentation

Expand Down
25 changes: 0 additions & 25 deletions R/consolidate_metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,6 @@
#'
#' *Permitted Values*: `"none"`, `"message"`, `"warning"`, `"error"`
#'
#' @param check_keys Check keys?
#'
#' `r lifecycle::badge("deprecated")` Please use `check_type` instead.
#'
#' If `"warning"` or `"error"` is specified, a message is issued if the key
#' variables (`key_vars`) are not a unique key in all of the input datasets
#' (`datasets`).
#'
#' *Permitted Values*: `"none"`, `"warning"`, `"error"`
#'
#' @param check_type Check uniqueness?
#'
#' If `"warning"` or `"error"` is specified, a message is issued if the key
Expand Down Expand Up @@ -89,7 +79,6 @@ consolidate_metadata <- function(datasets,
key_vars,
source_var = SOURCE,
check_vars = "warning",
check_keys,
check_type = "error") {
assert_list_of(datasets, cls = "data.frame", named = TRUE)
assert_vars(key_vars)
Expand All @@ -100,20 +89,6 @@ consolidate_metadata <- function(datasets,
values = c("none", "message", "warning", "error"),
case_sensitive = FALSE
)
if (!is_missing(check_keys)) {
deprecate_stop(
"1.1.0",
"consolidate_metadata(check_keys = )",
"consolidate_metadata(check_type = )"
)
check_type <-
assert_character_scalar(
check_keys,
values = c("none", "warning", "error"),
case_sensitive = FALSE,
optional = TRUE
)
}
check_type <-
assert_character_scalar(
check_type,
Expand Down
38 changes: 0 additions & 38 deletions R/derive_extreme_event.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,6 @@
#' A named list of datasets is expected. The `dataset_name` field of `event()`
#' and `event_joined()` refers to the dataset provided in the list.
#'
#' @param ignore_event_order Ignore event order
#'
#' `r lifecycle::badge("deprecated")`
#'
#' This argument is *deprecated*. If event order should be ignored, please
#' specify neither `ignore_event_order` nor `tmp_event_nr_var`. If the event
#' order should be considered, don't specify `ignore_event_order` but specify
#' `tmp_event_nr_var` and and the specified variable to `order`.
#'
#' If the argument is set to `TRUE`, all events defined by `events` are
#' considered equivalent. If there is more than one observation per by group
#' the first or last (with respect to `mode` and `order`) is select without
#' taking the order of the events into account.
#'
#' *Permitted Values:* `TRUE`, `FALSE`
#'
#' @param keep_source_vars Variables to keep from the source dataset
#'
#' For each event the specified variables are kept from the selected
Expand Down Expand Up @@ -353,7 +337,6 @@ derive_extreme_event <- function(dataset = NULL,
order,
mode,
source_datasets = NULL,
ignore_event_order = NULL,
check_type = "warning",
set_values_to = NULL,
keep_source_vars = exprs(everything())) {
Expand Down Expand Up @@ -382,27 +365,6 @@ derive_extreme_event <- function(dataset = NULL,
)
)

if (!is.null(ignore_event_order)) {
if (ignore_event_order) {
deprecate_details <- paste(
"The event order is ignored by default.",
"Please remove `ignore_event_order = TRUE` from the call.",
sep = "\n"
)
} else {
deprecate_details <- c(
"Please remove `ignore_event_order = FALSE` from the call.",
"Specify `tmp_event_nr_var`.",
"Add the specified variable to `order`."
)
}
deprecate_stop(
"1.1.0",
"derive_extreme_event(ignore_event_order=)",
"derive_extreme_event(tmp_event_nr_var=)",
details = deprecate_details
)
}
tmp_event_nr_var <- assert_symbol(enexpr(tmp_event_nr_var), optional = TRUE)
check_type <-
assert_character_scalar(
Expand Down
60 changes: 2 additions & 58 deletions R/derive_merged.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,6 @@
#'
#' *Permitted Values*: `"first"`, `"last"`, `NULL`
#'
#' @param match_flag Match flag
#'
#' `r lifecycle::badge("deprecated")` Please use `exist_flag` instead.
#'
#' If the argument is specified (e.g., `match_flag = FLAG`), the specified
#' variable (e.g., `FLAG`) is added to the input dataset. This variable will
#' be `TRUE` for all selected records from `dataset_add` which are merged into
#' the input dataset, and `NA` otherwise.
#'
#' *Permitted Values*: Variable name
#'
#' @param exist_flag Exist flag
#'
#' If the argument is specified (e.g., `exist_flag = FLAG`), the specified
Expand Down Expand Up @@ -321,7 +310,6 @@ derive_vars_merged <- function(dataset,
new_vars = NULL,
filter_add = NULL,
mode = NULL,
match_flag,
exist_flag = NULL,
true_value = "Y",
false_value = NA_character_,
Expand All @@ -344,14 +332,7 @@ derive_vars_merged <- function(dataset,
extract_vars(new_vars)
)
)
if (!is_missing(enexpr(match_flag))) {
deprecate_stop(
"1.1.0",
"derive_vars_merged(match_flag =)",
"derive_vars_merged(exist_flag =)"
)
exist_flag <- assert_symbol(enexpr(match_flag), optional = TRUE)
}

exist_flag <- assert_symbol(enexpr(exist_flag), optional = TRUE)
assert_atomic_vector(true_value, optional = TRUE)
assert_atomic_vector(false_value, optional = TRUE)
Expand Down Expand Up @@ -814,13 +795,6 @@ get_not_mapped <- function() {
#' The variables specified by the `by_vars` and the variables used on the left
#' hand sides of the `new_vars` arguments are expected.
#'
#' @param new_var Variable to add
#'
#' `r lifecycle::badge("deprecated")` Please use `new_vars` instead.
#'
#' The specified variable is added to the input dataset (`dataset`) and set to
#' the summarized values.
#'
#' @param by_vars Grouping variables
#'
#' The expressions on the left hand sides of `new_vars` are evaluated by the
Expand Down Expand Up @@ -855,21 +829,6 @@ get_not_mapped <- function() {
#'
#' *Permitted Values*: a condition
#'
#' @param analysis_var Analysis variable
#'
#' `r lifecycle::badge("deprecated")` Please use `new_vars` instead.
#'
#' The values of the specified variable are summarized by the function
#' specified for `summary_fun`.
#'
#' @param summary_fun Summary function
#'
#' `r lifecycle::badge("deprecated")` Please use `new_vars` instead.
#'
#' The specified function that takes as input `analysis_var` and performs the
#' calculation. This can include built-in functions as well as user defined
#' functions, for example `mean` or `function(x) mean(x, na.rm = TRUE)`.
#'
#' @inheritParams derive_vars_merged
#'
#' @details
Expand Down Expand Up @@ -959,11 +918,8 @@ derive_var_merged_summary <- function(dataset,
dataset_add,
by_vars,
new_vars = NULL,
new_var,
filter_add = NULL,
missing_values = NULL,
analysis_var,
summary_fun) {
missing_values = NULL) {
assert_vars(by_vars)
by_vars_left <- replace_values_by_names(by_vars)
by_vars_right <- chr2vars(paste(vars2chr(by_vars)))
Expand All @@ -980,18 +936,6 @@ derive_var_merged_summary <- function(dataset,
required_vars = expr_c(by_vars_right, extract_vars(new_vars))
)

if (!missing(new_var) || !missing(analysis_var) || !missing(summary_fun)) {
deprecate_stop(
"1.1.0",
I("derive_var_merged_summary(new_var = , anaylsis_var = , summary_fun = )"),
"derive_var_merged_summary(new_vars = )"
)
new_var <- assert_symbol(enexpr(new_var))
analysis_var <- assert_symbol(enexpr(analysis_var))
assert_s3_class(summary_fun, "function")
new_vars <- exprs(!!new_var := {{ summary_fun }}(!!analysis_var), !!!new_vars)
}

# Summarise the analysis value and merge to the original dataset
derive_vars_merged(
dataset,
Expand Down
42 changes: 0 additions & 42 deletions R/derive_param_exposure.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@
#' Observations from the specified dataset are going to be used to calculate and added
#' as new records to the input dataset (`dataset`).
#'
#'
#' @param filter
#'
#' `r lifecycle::badge("deprecated")` Please use `filter_add` instead.
#'
#' Filter condition as logical expression to apply during
#' summary calculation. By default, filtering expressions are computed within
#' `by_vars` as this will help when an aggregating, lagging, or ranking
#' function is involved.
#'
#' For example,
#'
#' + `filter = (AVAL > mean(AVAL, na.rm = TRUE))` will filter all `AVAL`
#' values greater than mean of `AVAL` with in `by_vars`.
#' + `filter = (dplyr::n() > 2)` will filter n count of `by_vars` greater
#' than 2.
#'
#' @param filter_add Filter condition as logical expression to apply during
#' summary calculation. By default, filtering expressions are computed within
#' `by_vars` as this will help when an aggregating, lagging, or ranking
Expand All @@ -49,13 +32,6 @@
#'
#' *Permitted Values:* A character of `PARAMCD` value
#'
#' @param analysis_var Analysis variable.
#'
#' @param summary_fun Function that takes as an input the `analysis_var` and
#' performs the calculation.
#' This can include built-in functions as well as user defined functions,
#' for example `mean` or `function(x) mean(x, na.rm = TRUE)`.
#'
#' @param by_vars Grouping variables
#'
#' For each group defined by `by_vars` an observation is added to the output
Expand Down Expand Up @@ -164,19 +140,9 @@ derive_param_exposure <- function(dataset = NULL,
dataset_add,
by_vars,
input_code,
analysis_var,
summary_fun,
filter = NULL,
filter_add = NULL,
set_values_to = NULL) {
by_vars <- assert_vars(by_vars)
if (!missing(analysis_var) || !missing(summary_fun)) {
deprecate_stop(
"1.1.0",
I("derive_param_exposure(anaylsis_var = , summary_fun = )"),
"derive_param_exposure(set_values_to = )"
)
}

dtm <- c("ASTDTM", "AENDTM") %in% colnames(dataset)
dt <- c("ASTDT", "AENDT") %in% colnames(dataset)
Expand All @@ -203,14 +169,6 @@ derive_param_exposure <- function(dataset = NULL,
required_vars = expr_c(by_vars, exprs(PARAMCD), dates)
)

if (!missing(filter)) {
deprecate_stop(
"1.1.0",
I("derive_param_exposure(filter = )"),
"derive_param_exposure(filter_add = )"
)
filter_add <- assert_filter_cond(enexpr(filter), optional = TRUE)
}
filter_add <- assert_filter_cond(enexpr(filter_add), optional = TRUE)
assert_varval_list(set_values_to, required_elements = "PARAMCD")
assert_param_does_not_exist(dataset, set_values_to$PARAMCD)
Expand Down
40 changes: 0 additions & 40 deletions R/derive_summary_records.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,6 @@
#'
#' `r roxygen_param_by_vars()`
#'
#' @param filter
#'
#' `r lifecycle::badge("deprecated")` Please use `filter_add` instead.
#'
#' Filter condition as logical expression to apply during
#' summary calculation. By default, filtering expressions are computed within
#' `by_vars` as this will help when an aggregating, lagging, or ranking
#' function is involved.
#'
#' For example,
#'
#' + `filter = (AVAL > mean(AVAL, na.rm = TRUE))` will filter all `AVAL`
#' values greater than mean of `AVAL` with in `by_vars`.
#' + `filter = (dplyr::n() > 2)` will filter n count of `by_vars` greater
#' than 2.
#'
#' @param filter_add Filter condition as logical expression to apply during
#' summary calculation. By default, filtering expressions are computed within
#' `by_vars` as this will help when an aggregating, lagging, or ranking
Expand Down Expand Up @@ -89,8 +73,6 @@
#' *Permitted Values*: named list of expressions, e.g.,
#' `exprs(AVAL = -9999)`
#'
#' @inheritParams get_summary_records
#'
#' @return A data frame with derived records appended to original dataset.
#'
#' @family der_prm_bds_findings
Expand Down Expand Up @@ -191,10 +173,7 @@ derive_summary_records <- function(dataset = NULL,
dataset_add,
dataset_ref = NULL,
by_vars,
filter = NULL,
filter_add = NULL,
analysis_var,
summary_fun,
set_values_to,
missing_values = NULL) {
assert_vars(by_vars)
Expand All @@ -209,25 +188,6 @@ derive_summary_records <- function(dataset = NULL,
assert_varval_list(set_values_to)
assert_expr_list(missing_values, named = TRUE, optional = TRUE)

if (!missing(analysis_var) || !missing(summary_fun)) {
deprecate_stop(
"1.1.0",
I("derive_summary_records(anaylsis_var = , summary_fun = )"),
"derive_summary_records(set_values_to = )"
)
analysis_var <- assert_symbol(enexpr(analysis_var))
assert_s3_class(summary_fun, "function")
set_values_to <- exprs(!!analysis_var := {{ summary_fun }}(!!analysis_var), !!!set_values_to)
}

if (!missing(filter)) {
deprecate_stop(
"1.1.0",
I("derive_summary_records(filter = )"),
"derive_summary_records(filter_add = )"
)
filter_add <- assert_filter_cond(enexpr(filter), optional = TRUE)
}
filter_add <- assert_filter_cond(enexpr(filter_add), optional = TRUE)

summary_records <- dataset_add %>%
Expand Down
Loading

0 comments on commit d4ec9ee

Please sign in to comment.