Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #2185 additional implementation of keep_source_vars #2215

Closed
wants to merge 13 commits into from
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ were enhanced such that more than one summary variable can be derived, e.g.,
allow more control of the selection of records. It creates a temporary variable
for the event number, which can be used in `order`. (#2140)

- The `keep_source_vars` argument was added to `derive_param_tte()` for consistency (#2185)

## Breaking Changes

- `derive_extreme_records()` the `dataset_add` argument is now mandatory. (#2139)
Expand Down
13 changes: 11 additions & 2 deletions R/derive_param_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@
#'
#' A list of symbols created using `exprs()` is expected.
#'
#' @param keep_source_vars Variables to be kept in the new records
#'
#' A named list or tidyselect expressions created by `exprs()` defining the
#' variables to be kept for the new records. The variables specified for
#' `by_vars` and `set_values_to` need not be specified here as they are kept
#' automatically.
#'
#'
#' @details The following steps are performed to create the observations of the
#' new parameter:
#'
Expand Down Expand Up @@ -320,7 +328,8 @@ derive_param_tte <- function(dataset = NULL,
censor_conditions,
create_datetime = FALSE,
set_values_to,
subject_keys = get_admiral_option("subject_keys")) {
subject_keys = get_admiral_option("subject_keys"),
keep_source_vars = exprs(everything())) {
# checking and quoting #
assert_data_frame(dataset, optional = TRUE)
assert_vars(by_vars, optional = TRUE)
Expand Down Expand Up @@ -445,7 +454,7 @@ derive_param_tte <- function(dataset = NULL,
}

# -vars2chr(by_vars) does not work for 3.5 #
new_param <- select(new_param, !!!negate_vars(by_vars))
new_param <- select(new_param, !!!negate_vars(by_vars), !!!keep_source_vars)
}

# add new parameter to input dataset #
Expand Down
10 changes: 9 additions & 1 deletion man/derive_param_tte.Rd

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

3 changes: 2 additions & 1 deletion tests/testthat/test-derive_param_tte.R
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ test_that("derive_param_tte Test 5: by_vars parameter works correctly", {
PARAM = paste("Time to First", AEDECOD, "Adverse Event"),
PARCAT1 = "TTAE",
PARCAT2 = AEDECOD
)
),
keep_source_vars = exprs(USUBJID)
),
expected_output,
keys = c("USUBJID", "PARAMCD")
Expand Down
Loading