From 0a278a856499fd5d30cd307b0731b213a7317616 Mon Sep 17 00:00:00 2001 From: StefanThoma <40463122+StefanThoma@users.noreply.github.com> Date: Wed, 30 Aug 2023 15:05:58 +0200 Subject: [PATCH 1/2] Closes #306 argument descriptions added to table (#320) argument descriptions added to table Co-authored-by: Zelos Zhu --- vignettes/programming_strategy.Rmd | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vignettes/programming_strategy.Rmd b/vignettes/programming_strategy.Rmd index 1bf4101a..724f20f4 100644 --- a/vignettes/programming_strategy.Rmd +++ b/vignettes/programming_strategy.Rmd @@ -208,15 +208,16 @@ Arguments which expect a boolean or boolean vector must start with a verb, e.g., Arguments which only expect one value or variable name must be a singular version of the word(s), e.g., `missing_value` or `new_var`. Arguments which expect several values or variable names (as a list, expressions, etc.) must be a plural version of the word(s), e.g., `missing_values` or `new_vars`. ## List of Common Arguments - -| Argument Name | Description | +| Argument Name | Description | |------------------|--------------------------------------------------------------------------------------------------------------------| | `dataset` | The input dataset. Expects a data.frame or a tibble. | +| `dataset_ref` | The reference dataset, e.g. ADSL. Typically includes just one observation per subject. | +| `dataset_add` | An additional dataset. Used in some `derive_xx` and `filter_xx` functions to access variables from an additional dataset. | | `by_vars` | Variables to group by. | -| `order` | List of expressions for sorting a dataset, e.g., `exprs(PARAMCD, AVISITN, desc(AVAL))`. | +| `order` | List of expressions for sorting a dataset, e.g., `exprs(PARAMCD, AVISITN, desc(AVAL))`. | | `new_var` | Name of a single variable to be added to the dataset. | | `new_vars` | List of variables to be added to the dataset. | -| `new_var_unit` | Name of the unit variable to be added. It should be the unit of the variable specified for the `new_var` argument. | +| `new_var_unit` | Name of the unit variable to be added. It should be the unit of the variable specified for the `new_var` argument. | | `filter` | Expression to filter a dataset, e.g., `PARAMCD == "TEMP"`. | | `start_date` | The start date of an event/interval. Expects a date object. | | `end_date` | The end date of an event/interval. Expects a date object. | @@ -226,7 +227,7 @@ Arguments which only expect one value or variable name must be a singular versio | `set_values_to` | List of variable name-value pairs. Use `process_set_values_to()` for processing the value and providing user friendly error messages. | | `subject_keys` | Variables to uniquely identify a subject, defaults to `exprs(STUDYID, USUBJID)`. In function formals, use `subject_keys = get_admiral_option("subject_keys")` | | `keep_source_vars` | Specifies which variables from the selected observations should be kept. The default of the argument should be `everything()`. | -| `missing_value` | A singular value to be entered if the data is missing. | +| `missing_value` | A singular value to be entered if the data is missing. | | `missing_values` | A named list of expressions where the names are variables in the dataset and the values are a value to be entered if the data is missing, e.g., `exprs(BASEC = "MISSING", BASE = -1)`. | ## Source Code Formatting From c3d1237a78b104a5921e212e6a5f707cdce3de07 Mon Sep 17 00:00:00 2001 From: Zelos Zhu Date: Wed, 30 Aug 2023 12:37:26 -0400 Subject: [PATCH 2/2] Closes #316 remove messaging that includes "-" as year not handled (#317) * feat: #316 remove messaging that includes "-" as year not handled * feat: #316 replace warning message * chore: #316 fix warning message and typos * chore: #316 add news blurb --------- Co-authored-by: Zelos Zhu --- NEWS.md | 2 ++ R/warnings.R | 18 ++++-------------- tests/testthat/test-warnings.R | 7 ++++--- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/NEWS.md b/NEWS.md index 97bfa637..1631bf17 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ ## Updates of Existing Functions +- The messaging for `warn_if_invalid_dtc()` was updated to align with what the date/datetime functions in `admiral` currently do. (#316) + ## Breaking Changes - The following functions/arguments have been deprecated from previous admiral versions using the next phase of the deprecation process: (#288) diff --git a/R/warnings.R b/R/warnings.R index 8f6f3799..08834fc5 100644 --- a/R/warnings.R +++ b/R/warnings.R @@ -69,20 +69,10 @@ warn_if_invalid_dtc <- function(dtc, is_valid = is_valid_dtc(dtc)) { ) info <- paste0( - "The following ISO representations are handled: \n", - "2003-12-15T13:15:17.123\n", - "2003-12-15T13:15:17\n", - "2003-12-15T13:15\n", - "2003-12-15T13\n", - "2003-12-15\n", - "2003-12\n", - "2003\n", - "2003---15\n\n", - "The following ISO representations, and any other representation are NOT handled: \n", - "2003-12-15T-:15:18\n", - "2003-12-15T13:-:19\n", - "--12-15\n", - "-----T07:15" + "ISO representations of the form YYYY-MM-DDThh:mm:ss.ddd are expected, ", + "e.g., 2003-12-15T13:15:17.123. Missing parts at the end can be omitted. ", + "Missing parts in the middle must be represented by a dash, e.g., 2003---15.", + sep = "\n" ) warn(paste(main_msg, tbl, info, sep = "\n")) } diff --git a/tests/testthat/test-warnings.R b/tests/testthat/test-warnings.R index 23df263e..a69d84fd 100644 --- a/tests/testthat/test-warnings.R +++ b/tests/testthat/test-warnings.R @@ -21,11 +21,12 @@ test_that("warn_if_vars_exist Test 1: warning if a variable already exists in th ) }) -# warn_if_invalud_dtc ---- +# warn_if_invalid_dtc ---- ## Test 2: Warning if vector contains unknown datetime format ---- -test_that("warn_if_invalud_dtc Test 2: Warning if vector contains unknown datetime format", { +test_that("warn_if_invalid_dtc Test 2: Warning if vector contains unknown datetime format", { expect_warning( - warn_if_invalid_dtc(dtc = "20210406T12:30:30") + warn_if_invalid_dtc(dtc = "20210406T12:30:30"), + "Dataset contains incorrect datetime format:" ) })