From 97b6017b41634c975771333301b3dd89ee1443ef Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 14 May 2024 22:16:20 +0000 Subject: [PATCH] Built site for sdtm.oak: 0.0.0.9003@4371c41 --- 404.html | 2 +- CODE_OF_CONDUCT.html | 2 +- CONTRIBUTING.html | 2 +- LICENSE.html | 2 +- articles/algorithms.html | 2 +- articles/index.html | 2 +- articles/iso_8601.html | 2 +- articles/study_sdtm_spec.html | 2 +- authors.html | 6 +- index.html | 2 +- news/index.html | 9 +- pkgdown.yml | 2 +- pull_request_template.html | 2 +- reference/add_problems.html | 2 +- reference/any_problems.html | 2 +- reference/assert_capture_matrix.html | 2 +- reference/assert_ct_clst.html | 2 +- reference/assert_ct_spec.html | 2 +- reference/assert_dtc_fmt.html | 2 +- reference/assert_dtc_format.html | 2 +- reference/assign.html | 2 +- reference/assign_datetime.html | 352 +++++++++++++++++++++++ reference/clear_cache.html | 2 +- reference/coalesce_capture_matrices.html | 2 +- reference/complete_capture_matrix.html | 2 +- reference/contains_oak_id_vars.html | 2 +- reference/create_iso8601.html | 2 +- reference/ct_map.html | 2 +- reference/ct_mappings.html | 2 +- reference/ct_spec_example.html | 2 +- reference/ct_spec_vars.html | 12 +- reference/derive_study_day.html | 2 +- reference/dtc_formats.html | 2 +- reference/dttm_fmt_to_regex.html | 2 +- reference/find_int_gap.html | 2 +- reference/fmt_cmp.html | 2 +- reference/fmt_rg.html | 2 +- reference/format_iso8601.html | 2 +- reference/harcode.html | 2 +- reference/index.html | 7 +- reference/index_for_recode.html | 2 +- reference/iso8601_mon.html | 2 +- reference/iso8601_na.html | 2 +- reference/iso8601_sec.html | 2 +- reference/iso8601_truncate.html | 2 +- reference/iso8601_two_digits.html | 2 +- reference/iso8601_year.html | 2 +- reference/months_abb_regex.html | 2 +- reference/oak_id_vars.html | 2 +- reference/parse_dttm.html | 2 +- reference/parse_dttm_fmt.html | 2 +- reference/problems.html | 2 +- reference/pseq.html | 2 +- reference/read_ct_spec.html | 2 +- reference/read_ct_spec_example.html | 2 +- reference/recode.html | 2 +- reference/reg_matches.html | 2 +- reference/regex_or.html | 2 +- reference/sdtm.oak-package.html | 2 +- reference/sdtm_assign.html | 2 +- reference/sdtm_hardcode.html | 2 +- reference/str_to_anycase.html | 2 +- reference/yy_to_yyyy.html | 2 +- reference/zero_pad_whole_number.html | 2 +- search.json | 2 +- sitemap.xml | 3 + 66 files changed, 438 insertions(+), 71 deletions(-) create mode 100644 reference/assign_datetime.html diff --git a/404.html b/404.html index 5c649ec0..d9e64720 100644 --- a/404.html +++ b/404.html @@ -31,7 +31,7 @@ sdtm.oak - 0.0.0.9002 + 0.0.0.9003 + + + + + +
+
+
+ +
+

assign_datetime() maps one or more variables with date/time components in a +raw dataset to a target SDTM variable following the ISO8601 format.

+
+ +
+

Usage

+
assign_datetime(
+  raw_dat,
+  raw_var,
+  raw_fmt,
+  tgt_var,
+  raw_unk = c("UN", "UNK"),
+  tgt_dat = NULL,
+  id_vars = oak_id_vars(),
+  .warn = TRUE
+)
+
+ +
+

Arguments

+
raw_dat
+

The raw dataset (dataframe); must include the +variables passed in id_vars and raw_var.

+ + +
raw_var
+

The raw variable(s): a character vector indicating the name(s) +of the raw variable(s) in raw_dat with date or time components to be +parsed into a ISO8601 format variable in tgt_var.

+ + +
raw_fmt
+

A date/time parsing format. Either a character vector or a +list of character vectors. If a character vector is passed then each +element is taken as parsing format for each variable indicated in +raw_var. If a list is provided, then each element must be a character +vector of formats. The first vector of formats is used for parsing the +first variable in raw_var, and so on.

+ + +
tgt_var
+

The target SDTM variable: a single string indicating the name +of variable to be derived.

+ + +
raw_unk
+

A character vector of string literals to be regarded as +missing values during parsing.

+ + +
tgt_dat
+

Target dataset: a data frame to be merged against raw_dat by +the variables indicated in id_vars. This parameter is optional, see +section Value for how the output changes depending on this argument value.

+ + +
id_vars
+

Key variables to be used in the join between the raw dataset +(raw_dat) and the target data set (raw_dat).

+ + +
.warn
+

Whether to warn about parsing failures.

+ +
+
+

Value

+ + +

The returned data set depends on the value of tgt_dat:

  • If no target dataset is supplied, meaning that tgt_dat defaults to +NULL, then the returned data set is raw_dat, selected for the variables +indicated in id_vars, and a new extra column: the derived variable, as +indicated in tgt_var.

  • +
  • If the target dataset is provided, then it is merged with the raw data set +raw_dat by the variables indicated in id_vars, with a new column: the +derived variable, as indicated in tgt_var.

  • +
+ +
+

Examples

+
# `md1`: an example raw data set.
+md1 <-
+  tibble::tribble(
+    ~oak_id, ~raw_source, ~patient_number, ~MDBDR,        ~MDEDR,        ~MDETM,
+    1L,      "MD1",       375,             NA,            NA,            NA,
+    2L,      "MD1",       375,             "15-Sep-20",   NA,            NA,
+    3L,      "MD1",       376,             "17-Feb-21",   "17-Feb-21",   NA,
+    4L,      "MD1",       377,             "4-Oct-20",    NA,            NA,
+    5L,      "MD1",       377,             "20-Jan-20",   "20-Jan-20",   "10:00:00",
+    6L,      "MD1",       377,             "UN-UNK-2019", "UN-UNK-2019", NA,
+    7L,      "MD1",       377,             "20-UNK-2019", "20-UNK-2019", NA,
+    8L,      "MD1",       378,             "UN-UNK-2020", "UN-UNK-2020", NA,
+    9L,      "MD1",       378,             "26-Jan-20",   "26-Jan-20",   "07:00:00",
+    10L,     "MD1",       378,             "28-Jan-20",   "1-Feb-20",    NA,
+    11L,     "MD1",       378,             "12-Feb-20",   "18-Feb-20",   NA,
+    12L,     "MD1",       379,             "10-UNK-2020", "20-UNK-2020", NA,
+    13L,     "MD1",       379,             NA,            NA,            NA,
+    14L,     "MD1",       379,             NA,            "17-Feb-20",   NA
+  )
+
+# Using the raw data set `md1`, derive the variable CMSTDTC from MDBDR using
+# the parsing format (`raw_fmt`) `"d-m-y"` (day-month-year), while allowing
+# for the presence of special date component values (e.g. `"UN"` or `"UNK"`),
+# indicating that these values are missing/unknown (unk).
+cm1 <-
+  assign_datetime(
+    raw_dat = md1,
+    raw_var = "MDBDR",
+    raw_fmt = "d-m-y",
+    raw_unk = c("UN", "UNK"),
+    tgt_var = "CMSTDTC"
+  )
+
+cm1
+#> # A tibble: 14 × 4
+#>    oak_id raw_source patient_number CMSTDTC   
+#>     <int> <chr>               <dbl> <iso8601> 
+#>  1      1 MD1                   375 NA        
+#>  2      2 MD1                   375 2020-09-15
+#>  3      3 MD1                   376 2021-02-17
+#>  4      4 MD1                   377 2020-10-04
+#>  5      5 MD1                   377 2020-01-20
+#>  6      6 MD1                   377 2019      
+#>  7      7 MD1                   377 2019---20 
+#>  8      8 MD1                   378 2020      
+#>  9      9 MD1                   378 2020-01-26
+#> 10     10 MD1                   378 2020-01-28
+#> 11     11 MD1                   378 2020-02-12
+#> 12     12 MD1                   379 2020---10 
+#> 13     13 MD1                   379 NA        
+#> 14     14 MD1                   379 NA        
+
+# Inspect parsing failures associated with derivation of CMSTDTC.
+problems(cm1$CMSTDTC)
+#> # A tibble: 3 × 2
+#>     ..i MDBDR
+#>   <int> <chr>
+#> 1     1 NA   
+#> 2    13 NA   
+#> 3    14 NA   
+
+# `cm_inter`: an example target data set.
+cm_inter <-
+  tibble::tibble(
+    oak_id = 1L:14L,
+    raw_source = "MD1",
+    patient_number = c(
+      375, 375, 376, 377, 377, 377, 377, 378,
+      378, 378, 378, 379, 379, 379
+    ),
+    CMTRT = c(
+      "BABY ASPIRIN",
+      "CORTISPORIN",
+      "ASPIRIN",
+      "DIPHENHYDRAMINE HCL",
+      "PARCETEMOL",
+      "VOMIKIND",
+      "ZENFLOX OZ",
+      "AMITRYPTYLINE",
+      "BENADRYL",
+      "DIPHENHYDRAMINE HYDROCHLORIDE",
+      "TETRACYCLINE",
+      "BENADRYL",
+      "SOMINEX",
+      "ZQUILL"
+    ),
+    CMINDC = c(
+      "NA",
+      "NAUSEA",
+      "ANEMIA",
+      "NAUSEA",
+      "PYREXIA",
+      "VOMITINGS",
+      "DIARHHEA",
+      "COLD",
+      "FEVER",
+      "LEG PAIN",
+      "FEVER",
+      "COLD",
+      "COLD",
+      "PAIN"
+    )
+  )
+
+# Same derivation as above but now involving the merging with the target
+# data set `cm_inter`.
+cm2 <-
+  assign_datetime(
+    raw_dat = md1,
+    raw_var = "MDBDR",
+    raw_fmt = "d-m-y",
+    tgt_var = "CMSTDTC",
+    tgt_dat = cm_inter
+  )
+
+cm2
+#> # A tibble: 14 × 6
+#>    oak_id raw_source patient_number CMTRT                         CMINDC CMSTDTC
+#>     <int> <chr>               <dbl> <chr>                         <chr>  <iso86>
+#>  1      1 MD1                   375 BABY ASPIRIN                  NA     NA    …
+#>  2      2 MD1                   375 CORTISPORIN                   NAUSEA 2020-0…
+#>  3      3 MD1                   376 ASPIRIN                       ANEMIA 2021-0…
+#>  4      4 MD1                   377 DIPHENHYDRAMINE HCL           NAUSEA 2020-1…
+#>  5      5 MD1                   377 PARCETEMOL                    PYREX… 2020-0…
+#>  6      6 MD1                   377 VOMIKIND                      VOMIT… 2019  …
+#>  7      7 MD1                   377 ZENFLOX OZ                    DIARH… 2019--…
+#>  8      8 MD1                   378 AMITRYPTYLINE                 COLD   2020  …
+#>  9      9 MD1                   378 BENADRYL                      FEVER  2020-0…
+#> 10     10 MD1                   378 DIPHENHYDRAMINE HYDROCHLORIDE LEG P… 2020-0…
+#> 11     11 MD1                   378 TETRACYCLINE                  FEVER  2020-0…
+#> 12     12 MD1                   379 BENADRYL                      COLD   2020--…
+#> 13     13 MD1                   379 SOMINEX                       COLD   NA    …
+#> 14     14 MD1                   379 ZQUILL                        PAIN   NA    …
+
+# Inspect parsing failures associated with derivation of CMSTDTC.
+problems(cm2$CMSTDTC)
+#> # A tibble: 3 × 2
+#>     ..i MDBDR
+#>   <int> <chr>
+#> 1     1 NA   
+#> 2    13 NA   
+#> 3    14 NA   
+
+# Derive CMSTDTC using both MDEDR and MDETM variables.
+# Note that the format `"d-m-y"` is used for parsing MDEDR and `"H:M:S"` for
+# MDETM (correspondence is by positional matching).
+cm3 <-
+  assign_datetime(
+    raw_dat = md1,
+    raw_var = c("MDEDR", "MDETM"),
+    raw_fmt = c("d-m-y", "H:M:S"),
+    raw_unk = c("UN", "UNK"),
+    tgt_var = "CMSTDTC"
+  )
+
+cm3
+#> # A tibble: 14 × 4
+#>    oak_id raw_source patient_number CMSTDTC            
+#>     <int> <chr>               <dbl> <iso8601>          
+#>  1      1 MD1                   375 NA                 
+#>  2      2 MD1                   375 NA                 
+#>  3      3 MD1                   376 2021-02-17         
+#>  4      4 MD1                   377 NA                 
+#>  5      5 MD1                   377 2020-01-20T10:00:00
+#>  6      6 MD1                   377 2019               
+#>  7      7 MD1                   377 2019---20          
+#>  8      8 MD1                   378 2020               
+#>  9      9 MD1                   378 2020-01-26T07:00:00
+#> 10     10 MD1                   378 2020-02-01         
+#> 11     11 MD1                   378 2020-02-18         
+#> 12     12 MD1                   379 2020---20          
+#> 13     13 MD1                   379 NA                 
+#> 14     14 MD1                   379 2020-02-17         
+
+# Inspect parsing failures associated with derivation of CMSTDTC.
+problems(cm3$CMSTDTC)
+#> # A tibble: 12 × 3
+#>      ..i MDEDR       MDETM
+#>    <int> <chr>       <chr>
+#>  1     1 NA          NA   
+#>  2     2 NA          NA   
+#>  3     3 17-Feb-21   NA   
+#>  4     4 NA          NA   
+#>  5     6 UN-UNK-2019 NA   
+#>  6     7 20-UNK-2019 NA   
+#>  7     8 UN-UNK-2020 NA   
+#>  8    10 1-Feb-20    NA   
+#>  9    11 18-Feb-20   NA   
+#> 10    12 20-UNK-2020 NA   
+#> 11    13 NA          NA   
+#> 12    14 17-Feb-20   NA   
+
+
+
+
+ + +
+ + + +
+ + + + + + + diff --git a/reference/clear_cache.html b/reference/clear_cache.html index 7dad7b66..bdf86c71 100644 --- a/reference/clear_cache.html +++ b/reference/clear_cache.html @@ -20,7 +20,7 @@ sdtm.oak - 0.0.0.9002 + 0.0.0.9003