From 8f8172794602c6acef3d6fa81a302799cc072b9f Mon Sep 17 00:00:00 2001 From: Jeffrey Dickinson Date: Wed, 25 Oct 2023 17:31:32 +0000 Subject: [PATCH 1/3] #2139 chore: Make dataset_add mandatory for derive_extreme_records() --- NEWS.md | 2 + R/derive_extreme_records.R | 55 ++++++-------------- inst/templates/ad_adlb.R | 3 ++ inst/templates/ad_advs.R | 1 + man/derive_extreme_records.Rd | 44 ++++++---------- tests/testthat/test-derive_extreme_records.R | 17 +++--- vignettes/bds_finding.Rmd | 2 + 7 files changed, 50 insertions(+), 74 deletions(-) diff --git a/NEWS.md b/NEWS.md index 712816b14a..c912e23d14 100644 --- a/NEWS.md +++ b/NEWS.md @@ -15,6 +15,8 @@ were enhanced such that more than one summary variable can be derived, e.g., ## Breaking Changes +- `derive_extreme_records()` the `dataset_add` argument is now mandatory. (#2139) + - In `derive_summary_records()` and `get_summary_records()` the arguments `analysis_var` and `summary_fun` were deprecated in favor of `set_values_to`. (#1792) diff --git a/R/derive_extreme_records.R b/R/derive_extreme_records.R index f63698d17e..2c73a0fe0b 100644 --- a/R/derive_extreme_records.R +++ b/R/derive_extreme_records.R @@ -1,38 +1,28 @@ #' Add the First or Last Observation for Each By Group as New Records #' #' Add the first or last observation for each by group as new observations. The -#' new observations can be selected from the input dataset or an additional -#' dataset. This function can be used for adding the maximum or minimum value -#' as a separate visit. All variables of the selected observation are kept. This -#' distinguishes `derive_extreme_records()` from `derive_summary_records()`, +#' new observations can be selected from the source dataset. This function can +#' be used for adding the maximum or minimum value as a separate visit. +#' All variables of the selected observation are kept. This distinguishes +#' `derive_extreme_records()` from `derive_summary_records()`, #' where only the by variables are populated for the new records. #' #' @param dataset `r roxygen_param_dataset()` #' -#' If `dataset_add` is not specified, the new records are selected from the -#' input dataset. In this case the variables specified by `by_vars` and -#' `order` are expected. -#' #' @param dataset_ref Reference dataset #' #' The variables specified for `by_vars` are expected. For each #' observation of the specified dataset a new observation is added to the #' input dataset. #' -#' @param dataset_add Additional dataset -#' -#' Observations from the specified dataset are added as new records to the -#' input dataset (`dataset`). +#' @param dataset_add Source dataset #' -#' All observations in the specified dataset fulfilling the condition -#' specified by `filter_source` are considered. If `mode` and `order` are -#' specified, the first or last observation within each by group, defined by -#' `by_vars`, is selected. +#' The source dataset, which determines the by groups returned in the input dataset, +#' based on the groups that exist in this dataset after being subset by `filter_add`. #' -#' If the argument is not specified, the input dataset (`dataset`) is used. -#' -#' The variables specified by the `by_vars` and `order` argument (if -#' applicable) are expected. +#' The variables specified in the `by_vars` and `filter_add` parameters are expected +#' in this dataset. If `mode` and `order` are specified, the first or last observation +#' within each by group, defined by `by_vars`, is selected. #' #' @param by_vars Grouping variables #' @@ -40,7 +30,7 @@ #' #' *Permitted Values*: list of variables created by `exprs()` #' -#' @param filter_add Filter for additional dataset (`dataset_add`) +#' @param filter_add Filter for source dataset (`dataset_add`) #' #' Only observations in `dataset_add` fulfilling the specified condition are #' considered. @@ -56,7 +46,7 @@ #' @param check_type Check uniqueness? #' #' If `"warning"` or `"error"` is specified, the specified message is issued -#' if the observations of the (restricted) additional dataset are not unique +#' if the observations of the (restricted) source dataset are not unique #' with respect to the by variables and the order. #' #' *Permitted Values*: `"none"`, `"warning"`, `"error"` @@ -65,7 +55,7 @@ #' #' The specified variable is added to the output dataset. #' -#' For by groups with at least one observation in the additional dataset +#' For by groups with at least one observation in the source dataset #' (`dataset_add`) `exist_flag` is set to the value specified by the #' `true_value` argument. #' @@ -76,12 +66,12 @@ #' #' @param true_value True value #' -#' For new observations selected from the additional dataset (`dataset_add`), +#' For new observations selected from the source dataset (`dataset_add`), #' `exist_flag` is set to the specified value. #' #' @param false_value False value #' -#' For new observations not selected from the additional dataset +#' For new observations not selected from the source dataset #' (`dataset_add`), `exist_flag` is set to the specified value. #' #' @param keep_source_vars Variables to be kept in the new records @@ -104,7 +94,7 @@ #' @inheritParams derive_summary_records #' #' @details -#' 1. The additional dataset (`dataset_add`) is restricted as specified by the +#' 1. The source dataset (`dataset_add`) is restricted as specified by the #' `filter_add` argument. #' 1. For each group (with respect to the variables specified for the #' `by_vars` argument) the first or last observation (with respect to the @@ -284,8 +274,7 @@ derive_extreme_records <- function(dataset = NULL, ) assert_data_frame( dataset_add, - required_vars = expr_c(by_vars, extract_vars(order)), - optional = TRUE + required_vars = expr_c(by_vars, extract_vars(order)) ) assert_data_frame( dataset_ref, @@ -307,18 +296,8 @@ derive_extreme_records <- function(dataset = NULL, exist_flag <- assert_symbol(enexpr(exist_flag), optional = TRUE) filter_add <- assert_filter_cond(enexpr(filter_add), optional = TRUE) assert_varval_list(set_values_to) - if (is.null(dataset) && is.null(dataset_add)) { - abort(paste( - "Neither `dataset` nor `dataset_add` is specified.", - "At least one of them must be specified.", - sep = "\n" - )) - } # Create new observations - if (is.null(dataset_add)) { - dataset_add <- dataset - } new_add_obs <- filter_if(dataset_add, filter_add) if (!is.null(order)) { diff --git a/inst/templates/ad_adlb.R b/inst/templates/ad_adlb.R index 99194bf71d..74f636925a 100644 --- a/inst/templates/ad_adlb.R +++ b/inst/templates/ad_adlb.R @@ -380,6 +380,7 @@ adlb <- adlb %>% adlb <- adlb %>% # get MINIMUM value derive_extreme_records( + dataset_add = adlb, by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE), order = exprs(AVAL, ADT, AVISITN), mode = "first", @@ -393,6 +394,7 @@ adlb <- adlb %>% ) %>% # get MAXIMUM value derive_extreme_records( + dataset_add = adlb, by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE), order = exprs(desc(AVAL), ADT, AVISITN), mode = "first", @@ -406,6 +408,7 @@ adlb <- adlb %>% ) %>% # get LOV value derive_extreme_records( + dataset_add = adlb, by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE), order = exprs(ADT, AVISITN), mode = "last", diff --git a/inst/templates/ad_advs.R b/inst/templates/ad_advs.R index fd630e2c47..c38b2965d5 100644 --- a/inst/templates/ad_advs.R +++ b/inst/templates/ad_advs.R @@ -250,6 +250,7 @@ advs <- advs %>% # Assign TRTA, TRTP # Create End of Treatment Record derive_extreme_records( + dataset_add = advs, by_vars = exprs(STUDYID, USUBJID, PARAMCD, ATPTN), order = exprs(ADT, AVISITN, AVAL), mode = "last", diff --git a/man/derive_extreme_records.Rd b/man/derive_extreme_records.Rd index a394c9b104..d7ba959d59 100644 --- a/man/derive_extreme_records.Rd +++ b/man/derive_extreme_records.Rd @@ -21,26 +21,16 @@ derive_extreme_records( ) } \arguments{ -\item{dataset}{Input dataset +\item{dataset}{Input dataset} -If \code{dataset_add} is not specified, the new records are selected from the -input dataset. In this case the variables specified by \code{by_vars} and -\code{order} are expected.} +\item{dataset_add}{Source dataset -\item{dataset_add}{Additional dataset +The source dataset, which determines the by groups returned in the input dataset, +based on the groups that exist in this dataset after being subset by \code{filter_add}. -Observations from the specified dataset are added as new records to the -input dataset (\code{dataset}). - -All observations in the specified dataset fulfilling the condition -specified by \code{filter_source} are considered. If \code{mode} and \code{order} are -specified, the first or last observation within each by group, defined by -\code{by_vars}, is selected. - -If the argument is not specified, the input dataset (\code{dataset}) is used. - -The variables specified by the \code{by_vars} and \code{order} argument (if -applicable) are expected.} +The variables specified in the \code{by_vars} and \code{filter_add} parameters are expected +in this dataset. If \code{mode} and \code{order} are specified, the first or last observation +within each by group, defined by \code{by_vars}, is selected.} \item{dataset_ref}{Reference dataset @@ -69,7 +59,7 @@ each by group is added to the input dataset. \emph{Permitted Values:} \code{"first"}, \code{"last"}} -\item{filter_add}{Filter for additional dataset (\code{dataset_add}) +\item{filter_add}{Filter for source dataset (\code{dataset_add}) Only observations in \code{dataset_add} fulfilling the specified condition are considered.} @@ -77,7 +67,7 @@ considered.} \item{check_type}{Check uniqueness? If \code{"warning"} or \code{"error"} is specified, the specified message is issued -if the observations of the (restricted) additional dataset are not unique +if the observations of the (restricted) source dataset are not unique with respect to the by variables and the order. \emph{Permitted Values}: \code{"none"}, \code{"warning"}, \code{"error"}} @@ -86,7 +76,7 @@ with respect to the by variables and the order. The specified variable is added to the output dataset. -For by groups with at least one observation in the additional dataset +For by groups with at least one observation in the source dataset (\code{dataset_add}) \code{exist_flag} is set to the value specified by the \code{true_value} argument. @@ -97,12 +87,12 @@ For all other by groups \code{exist_flag} is set to the value specified by the \item{true_value}{True value -For new observations selected from the additional dataset (\code{dataset_add}), +For new observations selected from the source dataset (\code{dataset_add}), \code{exist_flag} is set to the specified value.} \item{false_value}{False value -For new observations not selected from the additional dataset +For new observations not selected from the source dataset (\code{dataset_add}), \code{exist_flag} is set to the specified value.} \item{keep_source_vars}{Variables to be kept in the new records @@ -140,15 +130,15 @@ added as new observations. } \description{ Add the first or last observation for each by group as new observations. The -new observations can be selected from the input dataset or an additional -dataset. This function can be used for adding the maximum or minimum value -as a separate visit. All variables of the selected observation are kept. This -distinguishes \code{derive_extreme_records()} from \code{derive_summary_records()}, +new observations can be selected from the source dataset. This function can +be used for adding the maximum or minimum value as a separate visit. +All variables of the selected observation are kept. This distinguishes +\code{derive_extreme_records()} from \code{derive_summary_records()}, where only the by variables are populated for the new records. } \details{ \enumerate{ -\item The additional dataset (\code{dataset_add}) is restricted as specified by the +\item The source dataset (\code{dataset_add}) is restricted as specified by the \code{filter_add} argument. \item For each group (with respect to the variables specified for the \code{by_vars} argument) the first or last observation (with respect to the diff --git a/tests/testthat/test-derive_extreme_records.R b/tests/testthat/test-derive_extreme_records.R index 53d34bc804..4be3dcbb13 100644 --- a/tests/testthat/test-derive_extreme_records.R +++ b/tests/testthat/test-derive_extreme_records.R @@ -23,6 +23,7 @@ test_that("derive_extreme_records Test 1: add last observation for each group", actual_output <- derive_extreme_records( input, + dataset_add = input, order = exprs(AVISITN, LBSEQ), by_vars = exprs(USUBJID), mode = "last", @@ -299,17 +300,13 @@ test_that("derive_extreme_records Test 5: latest evaluable tumor assessment date ) }) -## Test 6: error if no input data ---- -test_that("derive_extreme_records Test 6: error if no input data", { +## Test 6: error if no dataset_add ---- +test_that("derive_extreme_records Test 6: error if no dataset_add", { expect_error( derive_extreme_records( set_values_to = exprs(PARAMCD = "HELLO") ), - regexp = paste( - "Neither `dataset` nor `dataset_add` is specified.", - "At least one of them must be specified.", - sep = "\n" - ), + regexp = "`dataset_add` must be a data frame but is `NULL`", fixed = TRUE ) }) @@ -339,6 +336,7 @@ test_that("derive_extreme_records Test 7: keep vars in `keep_source_vars` in the actual_output <- derive_extreme_records( input, + dataset_add = input, order = exprs(AVISITN, LBSEQ), by_vars = exprs(USUBJID), mode = "last", @@ -377,6 +375,7 @@ test_that("derive_extreme_records Test 8: keep all vars in the new records when actual_output <- derive_extreme_records( input, + dataset_add = input, order = exprs(AVISITN, LBSEQ), by_vars = exprs(USUBJID), mode = "last", @@ -391,8 +390,8 @@ test_that("derive_extreme_records Test 8: keep all vars in the new records when ) }) -## Test 10: order vars from dataset_add ---- -test_that("derive_extreme_records Test 10: order vars from dataset_add", { +## Test 9: order vars from dataset_add ---- +test_that("derive_extreme_records Test 9: order vars from dataset_add", { bds <- tibble::tribble( ~USUBJID, ~PARAMCD, ~AVALC, "1", "PARAM", "1" diff --git a/vignettes/bds_finding.Rmd b/vignettes/bds_finding.Rmd index 20e2fbdf62..05a65d5494 100644 --- a/vignettes/bds_finding.Rmd +++ b/vignettes/bds_finding.Rmd @@ -927,6 +927,7 @@ assign a unique `AVISITN` value. ```{r eval=TRUE} advs_ex1 <- advs %>% derive_extreme_records( + dataset_add = advs, by_vars = exprs(STUDYID, USUBJID, PARAMCD), order = exprs(ADT, AVISITN, ATPTN, AVAL), mode = "last", @@ -956,6 +957,7 @@ and assign a unique `AVISITN` value. ```{r eval=TRUE} advs_ex1 <- advs %>% derive_extreme_records( + dataset_add = advs, by_vars = exprs(STUDYID, USUBJID, PARAMCD), order = exprs(AVAL, ADT, AVISITN, ATPTN), mode = "first", From 10ced2e70d484c4b3a502ff22e3b7e8f03dd13ba Mon Sep 17 00:00:00 2001 From: Jeffrey Dickinson Date: Wed, 25 Oct 2023 17:58:44 +0000 Subject: [PATCH 2/3] #2139 Add mandatory dataset_add to examples --- R/derive_extreme_records.R | 3 +++ man/derive_extreme_records.Rd | 3 +++ 2 files changed, 6 insertions(+) diff --git a/R/derive_extreme_records.R b/R/derive_extreme_records.R index 2c73a0fe0b..b33b1d31f4 100644 --- a/R/derive_extreme_records.R +++ b/R/derive_extreme_records.R @@ -139,6 +139,7 @@ #' # Specify the variables that need to be kept in the new records. #' derive_extreme_records( #' adlb, +#' dataset_add = adlb, #' by_vars = exprs(USUBJID), #' order = exprs(AVAL, AVISITN), #' mode = "first", @@ -155,6 +156,7 @@ #' # AVISITN. Set AVISITN = 98 and DTYPE = MAXIMUM for these new records. #' derive_extreme_records( #' adlb, +#' dataset_add = adlb, #' by_vars = exprs(USUBJID), #' order = exprs(desc(AVAL), AVISITN), #' mode = "first", @@ -169,6 +171,7 @@ #' # Set AVISITN = 99 and DTYPE = LOV for these new records. #' derive_extreme_records( #' adlb, +#' dataset_add = adlb, #' by_vars = exprs(USUBJID), #' order = exprs(AVISITN), #' mode = "last", diff --git a/man/derive_extreme_records.Rd b/man/derive_extreme_records.Rd index d7ba959d59..fc20cc57e3 100644 --- a/man/derive_extreme_records.Rd +++ b/man/derive_extreme_records.Rd @@ -175,6 +175,7 @@ adlb <- tribble( # Specify the variables that need to be kept in the new records. derive_extreme_records( adlb, + dataset_add = adlb, by_vars = exprs(USUBJID), order = exprs(AVAL, AVISITN), mode = "first", @@ -191,6 +192,7 @@ derive_extreme_records( # AVISITN. Set AVISITN = 98 and DTYPE = MAXIMUM for these new records. derive_extreme_records( adlb, + dataset_add = adlb, by_vars = exprs(USUBJID), order = exprs(desc(AVAL), AVISITN), mode = "first", @@ -205,6 +207,7 @@ derive_extreme_records( # Set AVISITN = 99 and DTYPE = LOV for these new records. derive_extreme_records( adlb, + dataset_add = adlb, by_vars = exprs(USUBJID), order = exprs(AVISITN), mode = "last", From 5e325b247426d3166ae04fe69c2c78cb2ba3b19d Mon Sep 17 00:00:00 2001 From: Jeffrey Dickinson Date: Tue, 31 Oct 2023 22:25:39 +0000 Subject: [PATCH 3/3] #2130 Chore: Update derive_extreme_records from review comments --- R/derive_extreme_records.R | 27 ++++++++------------ inst/templates/ad_adlb.R | 9 +++---- man/derive_extreme_records.Rd | 20 +++++++-------- tests/testthat/test-derive_extreme_records.R | 2 +- 4 files changed, 24 insertions(+), 34 deletions(-) diff --git a/R/derive_extreme_records.R b/R/derive_extreme_records.R index b33b1d31f4..af507e9ab5 100644 --- a/R/derive_extreme_records.R +++ b/R/derive_extreme_records.R @@ -1,7 +1,7 @@ #' Add the First or Last Observation for Each By Group as New Records #' #' Add the first or last observation for each by group as new observations. The -#' new observations can be selected from the source dataset. This function can +#' new observations can be selected from the additional dataset. This function can #' be used for adding the maximum or minimum value as a separate visit. #' All variables of the selected observation are kept. This distinguishes #' `derive_extreme_records()` from `derive_summary_records()`, @@ -15,9 +15,9 @@ #' observation of the specified dataset a new observation is added to the #' input dataset. #' -#' @param dataset_add Source dataset +#' @param dataset_add Additional dataset #' -#' The source dataset, which determines the by groups returned in the input dataset, +#' The additional dataset, which determines the by groups returned in the input dataset, #' based on the groups that exist in this dataset after being subset by `filter_add`. #' #' The variables specified in the `by_vars` and `filter_add` parameters are expected @@ -30,7 +30,7 @@ #' #' *Permitted Values*: list of variables created by `exprs()` #' -#' @param filter_add Filter for source dataset (`dataset_add`) +#' @param filter_add Filter for additional dataset (`dataset_add`) #' #' Only observations in `dataset_add` fulfilling the specified condition are #' considered. @@ -46,7 +46,7 @@ #' @param check_type Check uniqueness? #' #' If `"warning"` or `"error"` is specified, the specified message is issued -#' if the observations of the (restricted) source dataset are not unique +#' if the observations of the (restricted) additional dataset are not unique #' with respect to the by variables and the order. #' #' *Permitted Values*: `"none"`, `"warning"`, `"error"` @@ -55,7 +55,7 @@ #' #' The specified variable is added to the output dataset. #' -#' For by groups with at least one observation in the source dataset +#' For by groups with at least one observation in the additional dataset #' (`dataset_add`) `exist_flag` is set to the value specified by the #' `true_value` argument. #' @@ -66,12 +66,12 @@ #' #' @param true_value True value #' -#' For new observations selected from the source dataset (`dataset_add`), +#' For new observations selected from the additional dataset (`dataset_add`), #' `exist_flag` is set to the specified value. #' #' @param false_value False value #' -#' For new observations not selected from the source dataset +#' For new observations not selected from the additional dataset #' (`dataset_add`), `exist_flag` is set to the specified value. #' #' @param keep_source_vars Variables to be kept in the new records @@ -94,7 +94,7 @@ #' @inheritParams derive_summary_records #' #' @details -#' 1. The source dataset (`dataset_add`) is restricted as specified by the +#' 1. The additional dataset (`dataset_add`) is restricted as specified by the #' `filter_add` argument. #' 1. For each group (with respect to the variables specified for the #' `by_vars` argument) the first or last observation (with respect to the @@ -247,7 +247,7 @@ #' ) #' ) derive_extreme_records <- function(dataset = NULL, - dataset_add = NULL, + dataset_add, dataset_ref = NULL, by_vars = NULL, order = NULL, @@ -264,15 +264,8 @@ derive_extreme_records <- function(dataset = NULL, assert_expr_list(order, optional = TRUE) assert_expr_list(keep_source_vars, optional = TRUE) - if (is.null(dataset_add)) { - expected_vars <- expr_c(by_vars, extract_vars(order)) - } else { - expected_vars <- by_vars - } - assert_data_frame( dataset, - required_vars = expected_vars, optional = TRUE ) assert_data_frame( diff --git a/inst/templates/ad_adlb.R b/inst/templates/ad_adlb.R index 74f636925a..6307c8720e 100644 --- a/inst/templates/ad_adlb.R +++ b/inst/templates/ad_adlb.R @@ -384,8 +384,7 @@ adlb <- adlb %>% by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE), order = exprs(AVAL, ADT, AVISITN), mode = "first", - # "AVISITN < 9997" to evaluate only real visits - filter_add = (!is.na(AVAL) & ONTRTFL == "Y" & AVISITN < 9997), + filter_add = (!is.na(AVAL) & ONTRTFL == "Y"), set_values_to = exprs( AVISITN = 9997, AVISIT = "POST-BASELINE MINIMUM", @@ -398,8 +397,7 @@ adlb <- adlb %>% by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE), order = exprs(desc(AVAL), ADT, AVISITN), mode = "first", - # "AVISITN < 9997" to evaluate only real visits - filter_add = (!is.na(AVAL) & ONTRTFL == "Y" & AVISITN < 9997), + filter_add = (!is.na(AVAL) & ONTRTFL == "Y"), set_values_to = exprs( AVISITN = 9998, AVISIT = "POST-BASELINE MAXIMUM", @@ -412,8 +410,7 @@ adlb <- adlb %>% by_vars = exprs(STUDYID, USUBJID, PARAMCD, BASETYPE), order = exprs(ADT, AVISITN), mode = "last", - # "AVISITN < 9997" to evaluate only real visits - filter_add = (ONTRTFL == "Y" & AVISITN < 9997), + filter_add = (ONTRTFL == "Y"), set_values_to = exprs( AVISITN = 9999, AVISIT = "POST-BASELINE LAST", diff --git a/man/derive_extreme_records.Rd b/man/derive_extreme_records.Rd index fc20cc57e3..bbd508114d 100644 --- a/man/derive_extreme_records.Rd +++ b/man/derive_extreme_records.Rd @@ -6,7 +6,7 @@ \usage{ derive_extreme_records( dataset = NULL, - dataset_add = NULL, + dataset_add, dataset_ref = NULL, by_vars = NULL, order = NULL, @@ -23,9 +23,9 @@ derive_extreme_records( \arguments{ \item{dataset}{Input dataset} -\item{dataset_add}{Source dataset +\item{dataset_add}{Additional dataset -The source dataset, which determines the by groups returned in the input dataset, +The additional dataset, which determines the by groups returned in the input dataset, based on the groups that exist in this dataset after being subset by \code{filter_add}. The variables specified in the \code{by_vars} and \code{filter_add} parameters are expected @@ -59,7 +59,7 @@ each by group is added to the input dataset. \emph{Permitted Values:} \code{"first"}, \code{"last"}} -\item{filter_add}{Filter for source dataset (\code{dataset_add}) +\item{filter_add}{Filter for additional dataset (\code{dataset_add}) Only observations in \code{dataset_add} fulfilling the specified condition are considered.} @@ -67,7 +67,7 @@ considered.} \item{check_type}{Check uniqueness? If \code{"warning"} or \code{"error"} is specified, the specified message is issued -if the observations of the (restricted) source dataset are not unique +if the observations of the (restricted) additional dataset are not unique with respect to the by variables and the order. \emph{Permitted Values}: \code{"none"}, \code{"warning"}, \code{"error"}} @@ -76,7 +76,7 @@ with respect to the by variables and the order. The specified variable is added to the output dataset. -For by groups with at least one observation in the source dataset +For by groups with at least one observation in the additional dataset (\code{dataset_add}) \code{exist_flag} is set to the value specified by the \code{true_value} argument. @@ -87,12 +87,12 @@ For all other by groups \code{exist_flag} is set to the value specified by the \item{true_value}{True value -For new observations selected from the source dataset (\code{dataset_add}), +For new observations selected from the additional dataset (\code{dataset_add}), \code{exist_flag} is set to the specified value.} \item{false_value}{False value -For new observations not selected from the source dataset +For new observations not selected from the additional dataset (\code{dataset_add}), \code{exist_flag} is set to the specified value.} \item{keep_source_vars}{Variables to be kept in the new records @@ -130,7 +130,7 @@ added as new observations. } \description{ Add the first or last observation for each by group as new observations. The -new observations can be selected from the source dataset. This function can +new observations can be selected from the additional dataset. This function can be used for adding the maximum or minimum value as a separate visit. All variables of the selected observation are kept. This distinguishes \code{derive_extreme_records()} from \code{derive_summary_records()}, @@ -138,7 +138,7 @@ where only the by variables are populated for the new records. } \details{ \enumerate{ -\item The source dataset (\code{dataset_add}) is restricted as specified by the +\item The additional dataset (\code{dataset_add}) is restricted as specified by the \code{filter_add} argument. \item For each group (with respect to the variables specified for the \code{by_vars} argument) the first or last observation (with respect to the diff --git a/tests/testthat/test-derive_extreme_records.R b/tests/testthat/test-derive_extreme_records.R index 4be3dcbb13..a083da8404 100644 --- a/tests/testthat/test-derive_extreme_records.R +++ b/tests/testthat/test-derive_extreme_records.R @@ -306,7 +306,7 @@ test_that("derive_extreme_records Test 6: error if no dataset_add", { derive_extreme_records( set_values_to = exprs(PARAMCD = "HELLO") ), - regexp = "`dataset_add` must be a data frame but is `NULL`", + regexp = "argument \"dataset_add\" is missing, with no default", fixed = TRUE ) })