diff --git a/articles/iso_8601.html b/articles/iso_8601.html index d0e94e4d..585baad5 100644 --- a/articles/iso_8601.html +++ b/articles/iso_8601.html @@ -108,8 +108,9 @@

Introduction
 create_iso8601("2000 01 05", .format = "y m d")
-#> [1] "2000-01-05"
-create_iso8601("22:35:05", .format = "H:M:S")
+#> [1] "2000-01-05"
+
+create_iso8601("22:35:05", .format = "H:M:S")
 #> [1] "-----T22:35:05"

By default the .format parameter understands a few reserved characters:

@@ -129,7 +130,7 @@

Introduction
+
 create_iso8601("2000-01-05 22:35:05", .format = "y-m-d H:M:S")
 #> [1] "2000-01-05T22:35:05"
@@ -138,12 +139,12 @@

Multiple inputs

If you have dates and times in separate vectors then you will need to pass a format for each vector:

-
+
 create_iso8601("2000-01-05", "22:35:05", .format = c("y-m-d", "H:M:S"))
 #> [1] "2000-01-05T22:35:05"

In addition, like most R functions that take vectors as input, create_iso8601() is vectorized:

-
+
 date <- c("2000-01-05", "2001-12-25", "1980-06-18", "1979-09-07")
 time <- c("00:12:21", "22:35:05", "03:00:15", "07:09:00")
 create_iso8601(date, time, .format = c("y-m-d", "H:M:S"))
@@ -151,7 +152,7 @@ 

Multiple inputs#> [4] "1979-09-07T07:09:00"

But the number of elements in each of the inputs has to match or you will get an error:

-
+
 date <- c("2000-01-05", "2001-12-25", "1980-06-18", "1979-09-07")
 time <- "00:12:21"
 try(create_iso8601(date, time, .format = c("y-m-d", "H:M:S")))
@@ -160,7 +161,7 @@ 

Multiple inputsYou can combine individual date and time components coming in as separate inputs; here is a contrived example of year, month and day together, hour, and minute:

-
+
 year <- c("99", "84", "00", "80", "79", "1944", "1953")
 month_and_day <- c("jan 1", "apr 04", "mar 06", "jun 18", "sep 07", "sep 13", "sep 14")
 hour <- c("12", "13", "05", "23", "16", "16", "19")
@@ -171,7 +172,7 @@ 

Multiple inputsThe .format argument must be always named; otherwise, it will be treated as if it were one of the inputs and interpreted as missing.

-
+
 try(create_iso8601("2000-01-05", "y-m-d"))
 #> Error in create_iso8601("2000-01-05", "y-m-d") : 
 #>   argument ".format" is missing, with no default
@@ -181,50 +182,59 @@

Format variations
+
 create_iso8601("2000-01-05", .format = "y-m-d")
-#> [1] "2000-01-05"
-create_iso8601("2000 01 05", .format = "y m d")
-#> [1] "2000-01-05"
-create_iso8601("2000/01/05", .format = "y/m/d")
+#> [1] "2000-01-05"
+
+create_iso8601("2000 01 05", .format = "y m d")
+#> [1] "2000-01-05"
+
+create_iso8601("2000/01/05", .format = "y/m/d")
 #> [1] "2000-01-05"

Individual components may come in a different order, so adjust the format accordingly:

-
+
 create_iso8601("2000 01 05", .format = "y m d")
-#> [1] "2000-01-05"
-create_iso8601("05 01 2000", .format = "d m y")
-#> [1] "2000-01-05"
-create_iso8601("01 05, 2000", .format = "m d, y")
+#> [1] "2000-01-05"
+
+create_iso8601("05 01 2000", .format = "d m y")
+#> [1] "2000-01-05"
+
+create_iso8601("01 05, 2000", .format = "m d, y")
 #> [1] "2000-01-05"

All other individual characters given in the format are taken strictly, e.g. the number of spaces matters:

-
+
 date <- c("2000 01 05", "2000  01 05", "2000 01  05", "2000   01   05")
 create_iso8601(date, .format = "y m d")
-#> [1] "2000-01-05" NA           NA           NA
-create_iso8601(date, .format = "y  m d")
-#> [1] NA           "2000-01-05" NA           NA
-create_iso8601(date, .format = "y m  d")
-#> [1] NA           NA           "2000-01-05" NA
-create_iso8601(date, .format = "y   m   d")
+#> [1] "2000-01-05" NA           NA           NA
+
+create_iso8601(date, .format = "y  m d")
+#> [1] NA           "2000-01-05" NA           NA
+
+create_iso8601(date, .format = "y m  d")
+#> [1] NA           NA           "2000-01-05" NA
+
+create_iso8601(date, .format = "y   m   d")
 #> [1] NA           NA           NA           "2000-01-05"

The format can include regular expressions though:

-
+
 create_iso8601(date, .format = "y\\s+m\\s+d")
 #> [1] "2000-01-05" "2000-01-05" "2000-01-05" "2000-01-05"

By default, a streak of the reserved characters is treated as if only one was provided, so these formats are equivalent:

-
+
 date <- c("2000-01-05", "2001-12-25", "1980-06-18", "1979-09-07")
 time <- c("00:12:21", "22:35:05", "03:00:15", "07:09:00")
 create_iso8601(date, time, .format = c("y-m-d", "H:M:S"))
 #> [1] "2000-01-05T00:12:21" "2001-12-25T22:35:05" "1980-06-18T03:00:15"
-#> [4] "1979-09-07T07:09:00"
-create_iso8601(date, time, .format = c("yyyy-mm-dd", "HH:MM:SS"))
+#> [4] "1979-09-07T07:09:00"
+
+create_iso8601(date, time, .format = c("yyyy-mm-dd", "HH:MM:SS"))
 #> [1] "2000-01-05T00:12:21" "2001-12-25T22:35:05" "1980-06-18T03:00:15"
-#> [4] "1979-09-07T07:09:00"
-create_iso8601(date, time, .format = c("yyyyyyyy-m-dddddd", "H:MMMMM:SSSS"))
+#> [4] "1979-09-07T07:09:00"
+
+create_iso8601(date, time, .format = c("yyyyyyyy-m-dddddd", "H:MMMMM:SSSS"))
 #> [1] "2000-01-05T00:12:21" "2001-12-25T22:35:05" "1980-06-18T03:00:15"
 #> [4] "1979-09-07T07:09:00"
@@ -236,23 +246,27 @@

Multiple alternative formats
+
 date <- c("2000/01/01", "2000-01-02", "2000 01 03", "2000/01/04")
 create_iso8601(date, .format = "y-m-d")
-#> [1] NA           "2000-01-02" NA           NA
-create_iso8601(date, .format = "y m d")
-#> [1] NA           NA           "2000-01-03" NA
-create_iso8601(date, .format = "y/m/d")
-#> [1] "2000-01-01" NA           NA           "2000-01-04"
-create_iso8601(date, .format = list(c("y-m-d", "y m d", "y/m/d")))
+#> [1] NA           "2000-01-02" NA           NA
+
+create_iso8601(date, .format = "y m d")
+#> [1] NA           NA           "2000-01-03" NA
+
+create_iso8601(date, .format = "y/m/d")
+#> [1] "2000-01-01" NA           NA           "2000-01-04"
+
+create_iso8601(date, .format = list(c("y-m-d", "y m d", "y/m/d")))
 #> [1] "2000-01-01" "2000-01-02" "2000-01-03" "2000-01-04"

Consider the order in which you supply the formats, as it can be significant. If multiple formats could potentially match, the sequence determines which format is applied first.

-
+
 create_iso8601("07 04 2000", .format = list(c("d m y", "m d y")))
-#> [1] "2000-04-07"
-create_iso8601("07 04 2000", .format = list(c("m d y", "d m y")))
+#> [1] "2000-04-07"
+
+create_iso8601("07 04 2000", .format = list(c("m d y", "d m y")))
 #> [1] "2000-07-04"

Note that if you are passing alternative formats, then the .format argument must be a list whose length matches the @@ -272,36 +286,42 @@

Parsing of date or time componentssecond: is parsed from single or two-digit numbers with an optional fractional part. -
+
 # Years: two-digit or four-digit numbers.
 years <- c("0", "1", "00", "01", "15", "30", "50", "68", "69", "80", "99")
 create_iso8601(years, .format = "y")
 #>  [1] NA     NA     "2000" "2001" "2015" "2030" "2050" "2068" "1969" "1980"
-#> [11] "1999"
-
+#> [11] "1999"
+
+
 # Adjust the point where two-digits years are mapped to 2000's or 1900's.
 create_iso8601(years, .format = "y", .cutoff_2000 = 20L)
 #>  [1] NA     NA     "2000" "2001" "2015" "1930" "1950" "1968" "1969" "1980"
-#> [11] "1999"
-
+#> [11] "1999"
+
+
 # Both numeric months (two-digit only) and abbreviated months work out of the box
 months <- c("0", "00", "1", "01", "Jan", "jan")
 create_iso8601(months, .format = "m")
-#> [1] NA     "--00" NA     "--01" "--01" "--01"
-
+#> [1] NA     "--00" NA     "--01" "--01" "--01"
+
+
 # Month days: single or two-digit numbers, anything else results in NA.
 create_iso8601(c("1", "01", "001", "10", "20", "31"), .format = "d")
-#> [1] "----01" "----01" NA       "----10" "----20" "----31"
-
+#> [1] "----01" "----01" NA       "----10" "----20" "----31"
+
+
 # Hours
 create_iso8601(c("1", "01", "001", "10", "20", "31"), .format = "H")
-#> [1] "-----T01" "-----T01" NA         "-----T10" "-----T20" "-----T31"
-
+#> [1] "-----T01" "-----T01" NA         "-----T10" "-----T20" "-----T31"
+
+
 # Minutes
 create_iso8601(c("1", "01", "001", "10", "20", "60"), .format = "M")
 #> [1] "-----T-:01" "-----T-:01" NA           "-----T-:10" "-----T-:20"
-#> [6] "-----T-:60"
-
+#> [6] "-----T-:60"
+
+
 # Seconds
 create_iso8601(c("1", "01", "23.04", "001", "10", "20", "60"), .format = "S")
 #> [1] "-----T-:-:01"    "-----T-:-:01"    "-----T-:-:23.04" NA               
@@ -314,18 +334,21 @@ 

Allowing alternative date or t encoding missing values, then you can indicate those values as possible alternatives such that the parsing will tolerate them; use the .na argument:

-
+
 create_iso8601("U DEC 2019 14:00", .format = "d m y H:M")
-#> [1] NA
-create_iso8601("U DEC 2019 14:00", .format = "d m y H:M", .na = "U")
-#> [1] "2019-12--T14:00"
-
+#> [1] NA
+
+create_iso8601("U DEC 2019 14:00", .format = "d m y H:M", .na = "U")
+#> [1] "2019-12--T14:00"
+
+
 create_iso8601("U UNK 2019 14:00", .format = "d m y H:M")
-#> [1] NA
-create_iso8601("U UNK 2019 14:00", .format = "d m y H:M", .na = c("U", "UNK"))
+#> [1] NA
+
+create_iso8601("U UNK 2019 14:00", .format = "d m y H:M", .na = c("U", "UNK"))
 #> [1] "2019----T14:00"

In this case you could achieve the same result using regexps:

-
+
 create_iso8601("U UNK 2019 14:00", .format = "(d|U) (m|UNK) y H:M")
 #> [1] "2019----T14:00"
@@ -347,10 +370,11 @@

Changing reserved format characters minute components, thus freeing the "H" and "M" patterns from being interpreted as hours and minutes, and to be taken literally:

-
+
 create_iso8601("14H00M", .format = "HHMM")
-#> [1] NA
-create_iso8601("14H00M", .format = "xHwM", .fmt_c = fmt_cmp(hour = "x", min = "w"))
+#> [1] NA
+
+create_iso8601("14H00M", .format = "xHwM", .fmt_c = fmt_cmp(hour = "x", min = "w"))
 #> [1] "-----T14:00"

Note that you need to make sure that the format component regexps are mutually exclusive, i.e. they don’t have overlapping matches; otherwise @@ -358,7 +382,7 @@

Changing reserved format characters example both months and minutes could be represented by an "m" in the format resulting in an ambiguous format specification.

-
+
 fmt_cmp(hour = "h", min = "m")
 #> $sec
 #> [1] "S+"
@@ -379,8 +403,9 @@ 

Changing reserved format characters #> [1] "y+" #> #> attr(,"class") -#> [1] "fmt_c" -try(create_iso8601("14H00M", .format = "hHmM", .fmt_c = fmt_cmp(hour = "h", min = "m"))) +#> [1] "fmt_c"

+
+try(create_iso8601("14H00M", .format = "hHmM", .fmt_c = fmt_cmp(hour = "h", min = "m")))
 #> Error in purrr::map2(dots, .format, ~parse_dttm(dttm = .x, fmt = .y, na = .na,  : 
 #>    In index: 1.
 #> Caused by error in `purrr::map()` at sdtm.oak/R/dtc_parse_dttm.R:104:3:
diff --git a/pkgdown.yml b/pkgdown.yml
index 6bae60de..1b792d3e 100644
--- a/pkgdown.yml
+++ b/pkgdown.yml
@@ -5,7 +5,7 @@ articles:
   algorithms: algorithms.html
   iso_8601: iso_8601.html
   study_sdtm_spec: study_sdtm_spec.html
-last_built: 2024-05-14T22:15Z
+last_built: 2024-05-16T18:00Z
 urls:
   reference: https://pharmaverse.github.io/sdtm.oak/reference
   article: https://pharmaverse.github.io/sdtm.oak/articles
diff --git a/reference/assign_datetime.html b/reference/assign_datetime.html
index a74a1fbc..837cd62c 100644
--- a/reference/assign_datetime.html
+++ b/reference/assign_datetime.html
@@ -114,7 +114,7 @@ 

ArgumentsExamples# Note that if the controlled terminology mapping is restricted to a codelist # code, e.g. C71113, then only `"/day"` and `"Every 2 hours"` get mapped to # `"QD"` and `"Q2H"`, respectively; remaining terms won't match given the -# codelist code # restriction, and will be mapped to an uppercase version of +# codelist code restriction, and will be mapped to an uppercase version of # the original terms. ct_map(x = terms, ct_spec = ct_spec, ct_clst = "C71113") #> [1] "QD" "YES" "UNKNOWN" diff --git a/search.json b/search.json index 33022315..562231f0 100644 --- a/search.json +++ b/search.json @@ -1 +1 @@ -[{"path":"https://pharmaverse.github.io/sdtm.oak/CODE_OF_CONDUCT.html","id":null,"dir":"","previous_headings":"","what":"Contributor Code of Conduct","title":"Contributor Code of Conduct","text":"contributors maintainers project, pledge respect people contribute reporting issues, posting feature requests, updating documentation, submitting pull requests patches, activities. committed making participation project harassment-free experience everyone, regardless level experience, gender, gender identity expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion. Examples unacceptable behavior participants include use sexual language imagery, derogatory comments personal attacks, trolling, public private harassment, insults, unprofessional conduct. Project maintainers right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct. Project maintainers follow Code Conduct may removed project team. Instances abusive, harassing, otherwise unacceptable behavior may reported opening issue contacting one project maintainers. Code Conduct adapted Contributor Covenant (http://contributor-covenant.org), version 1.0.0, available http://contributor-covenant.org/version/1/0/0/","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contribution to {sdtm.oak}","title":"Contribution to {sdtm.oak}","text":"outlines propose change sdtm.oak package. detailed info contributing {sdtm.oak}, pharmaverse packages, please see Contribution Guide well Developer Guides Articles section {admiraldev} website. Please note try align best practices used R packages’ development processes - veteran developers familiar processes. However, deviate slightly best practices advise new contributors review package documentation accordingly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/CONTRIBUTING.html","id":"basics","dir":"","previous_headings":"","what":"Basics","title":"Contribution to {sdtm.oak}","text":"new contribution, user creates issue issue tab GitHub put backlog. issues can range bug identification /fixes, enhancements functions, documentation, tests new features. advise contact us issue created via Slack (don’t access, use link join). can discuss details align expectations familiar sdtm.oak philosophy programming strategy. team try review issues within next backlog meeting give initial feedback. Since 100% fully resourced software development team might issues take longer respond depending amount overall issues.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"Apache License","title":"Apache License","text":"Version 2.0, January 2004 ","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_1-definitions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"1. Definitions","title":"Apache License","text":"“License” shall mean terms conditions use, reproduction, distribution defined Sections 1 9 document. “Licensor” shall mean copyright owner entity authorized copyright owner granting License. “Legal Entity” shall mean union acting entity entities control, controlled , common control entity. purposes definition, “control” means () power, direct indirect, cause direction management entity, whether contract otherwise, (ii) ownership fifty percent (50%) outstanding shares, (iii) beneficial ownership entity. “” (“”) shall mean individual Legal Entity exercising permissions granted License. “Source” form shall mean preferred form making modifications, including limited software source code, documentation source, configuration files. “Object” form shall mean form resulting mechanical transformation translation Source form, including limited compiled object code, generated documentation, conversions media types. “Work” shall mean work authorship, whether Source Object form, made available License, indicated copyright notice included attached work (example provided Appendix ). “Derivative Works” shall mean work, whether Source Object form, based (derived ) Work editorial revisions, annotations, elaborations, modifications represent, whole, original work authorship. purposes License, Derivative Works shall include works remain separable , merely link (bind name) interfaces , Work Derivative Works thereof. “Contribution” shall mean work authorship, including original version Work modifications additions Work Derivative Works thereof, intentionally submitted Licensor inclusion Work copyright owner individual Legal Entity authorized submit behalf copyright owner. purposes definition, “submitted” means form electronic, verbal, written communication sent Licensor representatives, including limited communication electronic mailing lists, source code control systems, issue tracking systems managed , behalf , Licensor purpose discussing improving Work, excluding communication conspicuously marked otherwise designated writing copyright owner “Contribution.” “Contributor” shall mean Licensor individual Legal Entity behalf Contribution received Licensor subsequently incorporated within Work.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_2-grant-of-copyright-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"2. Grant of Copyright License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable copyright license reproduce, prepare Derivative Works , publicly display, publicly perform, sublicense, distribute Work Derivative Works Source Object form.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_3-grant-of-patent-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"3. Grant of Patent License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable (except stated section) patent license make, made, use, offer sell, sell, import, otherwise transfer Work, license applies patent claims licensable Contributor necessarily infringed Contribution(s) alone combination Contribution(s) Work Contribution(s) submitted. institute patent litigation entity (including cross-claim counterclaim lawsuit) alleging Work Contribution incorporated within Work constitutes direct contributory patent infringement, patent licenses granted License Work shall terminate date litigation filed.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_4-redistribution","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"4. Redistribution","title":"Apache License","text":"may reproduce distribute copies Work Derivative Works thereof medium, without modifications, Source Object form, provided meet following conditions: () must give recipients Work Derivative Works copy License; (b) must cause modified files carry prominent notices stating changed files; (c) must retain, Source form Derivative Works distribute, copyright, patent, trademark, attribution notices Source form Work, excluding notices pertain part Derivative Works; (d) Work includes “NOTICE” text file part distribution, Derivative Works distribute must include readable copy attribution notices contained within NOTICE file, excluding notices pertain part Derivative Works, least one following places: within NOTICE text file distributed part Derivative Works; within Source form documentation, provided along Derivative Works; , within display generated Derivative Works, wherever third-party notices normally appear. contents NOTICE file informational purposes modify License. may add attribution notices within Derivative Works distribute, alongside addendum NOTICE text Work, provided additional attribution notices construed modifying License. may add copyright statement modifications may provide additional different license terms conditions use, reproduction, distribution modifications, Derivative Works whole, provided use, reproduction, distribution Work otherwise complies conditions stated License.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_5-submission-of-contributions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"5. Submission of Contributions","title":"Apache License","text":"Unless explicitly state otherwise, Contribution intentionally submitted inclusion Work Licensor shall terms conditions License, without additional terms conditions. Notwithstanding , nothing herein shall supersede modify terms separate license agreement may executed Licensor regarding Contributions.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_6-trademarks","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"6. Trademarks","title":"Apache License","text":"License grant permission use trade names, trademarks, service marks, product names Licensor, except required reasonable customary use describing origin Work reproducing content NOTICE file.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_7-disclaimer-of-warranty","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"7. Disclaimer of Warranty","title":"Apache License","text":"Unless required applicable law agreed writing, Licensor provides Work (Contributor provides Contributions) “” BASIS, WITHOUT WARRANTIES CONDITIONS KIND, either express implied, including, without limitation, warranties conditions TITLE, NON-INFRINGEMENT, MERCHANTABILITY, FITNESS PARTICULAR PURPOSE. solely responsible determining appropriateness using redistributing Work assume risks associated exercise permissions License.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_8-limitation-of-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"8. Limitation of Liability","title":"Apache License","text":"event legal theory, whether tort (including negligence), contract, otherwise, unless required applicable law (deliberate grossly negligent acts) agreed writing, shall Contributor liable damages, including direct, indirect, special, incidental, consequential damages character arising result License use inability use Work (including limited damages loss goodwill, work stoppage, computer failure malfunction, commercial damages losses), even Contributor advised possibility damages.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_9-accepting-warranty-or-additional-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"9. Accepting Warranty or Additional Liability","title":"Apache License","text":"redistributing Work Derivative Works thereof, may choose offer, charge fee , acceptance support, warranty, indemnity, liability obligations /rights consistent License. However, accepting obligations, may act behalf sole responsibility, behalf Contributor, agree indemnify, defend, hold Contributor harmless liability incurred , claims asserted , Contributor reason accepting warranty additional liability. END TERMS CONDITIONS","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"appendix-how-to-apply-the-apache-license-to-your-work","dir":"","previous_headings":"","what":"APPENDIX: How to apply the Apache License to your work","title":"Apache License","text":"apply Apache License work, attach following boilerplate notice, fields enclosed brackets [] replaced identifying information. (Don’t include brackets!) text enclosed appropriate comment syntax file format. also recommend file class name description purpose included “printed page” copyright notice easier identification within third-party archives.","code":"Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/algorithms.html","id":"core-concept","dir":"Articles","previous_headings":"","what":"Core Concept","title":"Algorithms & Sub-Algorithms","text":"SDTM mappings defined algorithms transform collected (eCRF, eDT) source data target SDTM data model. Mapping algorithms backbone sdtm.oak - SDTM data transformation engine. Key Points: Algorithms can re-used across multiple SDTM domains. Algorithms pre-specified data collection standards MDR (applicable) Programming language agnostic - concept rely specific programming language implementation. OAK team implemented R functions. example reusing algorithm across multiple domains, variables, also non-standard","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/algorithms.html","id":"sub-algorithms","dir":"Articles","previous_headings":"","what":"Sub-algorithms","title":"Algorithms & Sub-Algorithms","text":"sdtm.oak supports two levels defining algorithms. example, SDTM mappings certain action taken condition met. cases, primary algorithm checks condition, sub-algorithm executes mappings condition met. Currently, sub-algorithms must provided main algorithms. IF_THEN_ELSE DATASET_LEVEL Algorithms can interchangeably used algorithms sub-algorithms seen (exhaustive list) permutation & combination algorithms & sub-algorithms creates endless possibilities accommodate different types mappings.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Converting dates, times or date-times to ISO 8601","text":"perform conversion ISO 8601 format need pass two key arguments: least one vector dates, times, date-times character type; date/time format via .format parameter instructs create_iso8601() date/time components expect. default .format parameter understands reserved characters: \"y\" year \"m\" month \"d\" day \"H\" hours \"M\" minutes \"S\" seconds Besides character vectors dates times, may also pass single vector date-times, provided adjust format:","code":"create_iso8601(\"2000 01 05\", .format = \"y m d\") #> [1] \"2000-01-05\" create_iso8601(\"22:35:05\", .format = \"H:M:S\") #> [1] \"-----T22:35:05\" create_iso8601(\"2000-01-05 22:35:05\", .format = \"y-m-d H:M:S\") #> [1] \"2000-01-05T22:35:05\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"multiple-inputs","dir":"Articles","previous_headings":"","what":"Multiple inputs","title":"Converting dates, times or date-times to ISO 8601","text":"dates times separate vectors need pass format vector: addition, like R functions take vectors input, create_iso8601() vectorized: number elements inputs match get error: can combine individual date time components coming separate inputs; contrived example year, month day together, hour, minute: .format argument must always named; otherwise, treated one inputs interpreted missing.","code":"create_iso8601(\"2000-01-05\", \"22:35:05\", .format = c(\"y-m-d\", \"H:M:S\")) #> [1] \"2000-01-05T22:35:05\" date <- c(\"2000-01-05\", \"2001-12-25\", \"1980-06-18\", \"1979-09-07\") time <- c(\"00:12:21\", \"22:35:05\", \"03:00:15\", \"07:09:00\") create_iso8601(date, time, .format = c(\"y-m-d\", \"H:M:S\")) #> [1] \"2000-01-05T00:12:21\" \"2001-12-25T22:35:05\" \"1980-06-18T03:00:15\" #> [4] \"1979-09-07T07:09:00\" date <- c(\"2000-01-05\", \"2001-12-25\", \"1980-06-18\", \"1979-09-07\") time <- \"00:12:21\" try(create_iso8601(date, time, .format = c(\"y-m-d\", \"H:M:S\"))) #> Error in create_iso8601(date, time, .format = c(\"y-m-d\", \"H:M:S\")) : #> All vectors in `...` must be of the same length. year <- c(\"99\", \"84\", \"00\", \"80\", \"79\", \"1944\", \"1953\") month_and_day <- c(\"jan 1\", \"apr 04\", \"mar 06\", \"jun 18\", \"sep 07\", \"sep 13\", \"sep 14\") hour <- c(\"12\", \"13\", \"05\", \"23\", \"16\", \"16\", \"19\") min <- c(\"0\", \"60\", \"59\", \"42\", \"44\", \"10\", \"13\") create_iso8601(year, month_and_day, hour, min, .format = c(\"y\", \"m d\", \"H\", \"M\")) #> [1] \"1999-01-01T12:00\" \"1984-04-04T13:60\" \"2000-03-06T05:59\" \"1980-06-18T23:42\" #> [5] \"1979-09-07T16:44\" \"1944-09-13T16:10\" \"1953-09-14T19:13\" try(create_iso8601(\"2000-01-05\", \"y-m-d\")) #> Error in create_iso8601(\"2000-01-05\", \"y-m-d\") : #> argument \".format\" is missing, with no default"},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"format-variations","dir":"Articles","previous_headings":"","what":"Format variations","title":"Converting dates, times or date-times to ISO 8601","text":".format parameter can easily accommodate variations format inputs: Individual components may come different order, adjust format accordingly: individual characters given format taken strictly, e.g. number spaces matters: format can include regular expressions though: default, streak reserved characters treated one provided, formats equivalent:","code":"create_iso8601(\"2000-01-05\", .format = \"y-m-d\") #> [1] \"2000-01-05\" create_iso8601(\"2000 01 05\", .format = \"y m d\") #> [1] \"2000-01-05\" create_iso8601(\"2000/01/05\", .format = \"y/m/d\") #> [1] \"2000-01-05\" create_iso8601(\"2000 01 05\", .format = \"y m d\") #> [1] \"2000-01-05\" create_iso8601(\"05 01 2000\", .format = \"d m y\") #> [1] \"2000-01-05\" create_iso8601(\"01 05, 2000\", .format = \"m d, y\") #> [1] \"2000-01-05\" date <- c(\"2000 01 05\", \"2000 01 05\", \"2000 01 05\", \"2000 01 05\") create_iso8601(date, .format = \"y m d\") #> [1] \"2000-01-05\" NA NA NA create_iso8601(date, .format = \"y m d\") #> [1] NA \"2000-01-05\" NA NA create_iso8601(date, .format = \"y m d\") #> [1] NA NA \"2000-01-05\" NA create_iso8601(date, .format = \"y m d\") #> [1] NA NA NA \"2000-01-05\" create_iso8601(date, .format = \"y\\\\s+m\\\\s+d\") #> [1] \"2000-01-05\" \"2000-01-05\" \"2000-01-05\" \"2000-01-05\" date <- c(\"2000-01-05\", \"2001-12-25\", \"1980-06-18\", \"1979-09-07\") time <- c(\"00:12:21\", \"22:35:05\", \"03:00:15\", \"07:09:00\") create_iso8601(date, time, .format = c(\"y-m-d\", \"H:M:S\")) #> [1] \"2000-01-05T00:12:21\" \"2001-12-25T22:35:05\" \"1980-06-18T03:00:15\" #> [4] \"1979-09-07T07:09:00\" create_iso8601(date, time, .format = c(\"yyyy-mm-dd\", \"HH:MM:SS\")) #> [1] \"2000-01-05T00:12:21\" \"2001-12-25T22:35:05\" \"1980-06-18T03:00:15\" #> [4] \"1979-09-07T07:09:00\" create_iso8601(date, time, .format = c(\"yyyyyyyy-m-dddddd\", \"H:MMMMM:SSSS\")) #> [1] \"2000-01-05T00:12:21\" \"2001-12-25T22:35:05\" \"1980-06-18T03:00:15\" #> [4] \"1979-09-07T07:09:00\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"multiple-alternative-formats","dir":"Articles","previous_headings":"","what":"Multiple alternative formats","title":"Converting dates, times or date-times to ISO 8601","text":"input vector contains values varying formats, single format may adequate encompass variations. situations, ’s advisable list multiple alternative formats. approach ensures format tried sequentially one matches data vector. Consider order supply formats, can significant. multiple formats potentially match, sequence determines format applied first. Note passing alternative formats, .format argument must list whose length matches number inputs.","code":"date <- c(\"2000/01/01\", \"2000-01-02\", \"2000 01 03\", \"2000/01/04\") create_iso8601(date, .format = \"y-m-d\") #> [1] NA \"2000-01-02\" NA NA create_iso8601(date, .format = \"y m d\") #> [1] NA NA \"2000-01-03\" NA create_iso8601(date, .format = \"y/m/d\") #> [1] \"2000-01-01\" NA NA \"2000-01-04\" create_iso8601(date, .format = list(c(\"y-m-d\", \"y m d\", \"y/m/d\"))) #> [1] \"2000-01-01\" \"2000-01-02\" \"2000-01-03\" \"2000-01-04\" create_iso8601(\"07 04 2000\", .format = list(c(\"d m y\", \"m d y\"))) #> [1] \"2000-04-07\" create_iso8601(\"07 04 2000\", .format = list(c(\"m d y\", \"d m y\"))) #> [1] \"2000-07-04\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"parsing-of-date-or-time-components","dir":"Articles","previous_headings":"","what":"Parsing of date or time components","title":"Converting dates, times or date-times to ISO 8601","text":"default, date time components parsed follows: year: either parsed two- four-digit year; month: either numeric month (single two-digit number) English abbreviated month name (e.g. Jan, Jun Dec) regardless case; month day: parsed two-digit numbers; hour minute: parsed single two-digit numbers; second: parsed single two-digit numbers optional fractional part.","code":"# Years: two-digit or four-digit numbers. years <- c(\"0\", \"1\", \"00\", \"01\", \"15\", \"30\", \"50\", \"68\", \"69\", \"80\", \"99\") create_iso8601(years, .format = \"y\") #> [1] NA NA \"2000\" \"2001\" \"2015\" \"2030\" \"2050\" \"2068\" \"1969\" \"1980\" #> [11] \"1999\" # Adjust the point where two-digits years are mapped to 2000's or 1900's. create_iso8601(years, .format = \"y\", .cutoff_2000 = 20L) #> [1] NA NA \"2000\" \"2001\" \"2015\" \"1930\" \"1950\" \"1968\" \"1969\" \"1980\" #> [11] \"1999\" # Both numeric months (two-digit only) and abbreviated months work out of the box months <- c(\"0\", \"00\", \"1\", \"01\", \"Jan\", \"jan\") create_iso8601(months, .format = \"m\") #> [1] NA \"--00\" NA \"--01\" \"--01\" \"--01\" # Month days: single or two-digit numbers, anything else results in NA. create_iso8601(c(\"1\", \"01\", \"001\", \"10\", \"20\", \"31\"), .format = \"d\") #> [1] \"----01\" \"----01\" NA \"----10\" \"----20\" \"----31\" # Hours create_iso8601(c(\"1\", \"01\", \"001\", \"10\", \"20\", \"31\"), .format = \"H\") #> [1] \"-----T01\" \"-----T01\" NA \"-----T10\" \"-----T20\" \"-----T31\" # Minutes create_iso8601(c(\"1\", \"01\", \"001\", \"10\", \"20\", \"60\"), .format = \"M\") #> [1] \"-----T-:01\" \"-----T-:01\" NA \"-----T-:10\" \"-----T-:20\" #> [6] \"-----T-:60\" # Seconds create_iso8601(c(\"1\", \"01\", \"23.04\", \"001\", \"10\", \"20\", \"60\"), .format = \"S\") #> [1] \"-----T-:-:01\" \"-----T-:-:01\" \"-----T-:-:23.04\" NA #> [5] \"-----T-:-:10\" \"-----T-:-:20\" \"-----T-:-:60\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"allowing-alternative-date-or-time-values","dir":"Articles","previous_headings":"","what":"Allowing alternative date or time values","title":"Converting dates, times or date-times to ISO 8601","text":"date time component values include special values, e.g. values encoding missing values, can indicate values possible alternatives parsing tolerate ; use .na argument: case achieve result using regexps:","code":"create_iso8601(\"U DEC 2019 14:00\", .format = \"d m y H:M\") #> [1] NA create_iso8601(\"U DEC 2019 14:00\", .format = \"d m y H:M\", .na = \"U\") #> [1] \"2019-12--T14:00\" create_iso8601(\"U UNK 2019 14:00\", .format = \"d m y H:M\") #> [1] NA create_iso8601(\"U UNK 2019 14:00\", .format = \"d m y H:M\", .na = c(\"U\", \"UNK\")) #> [1] \"2019----T14:00\" create_iso8601(\"U UNK 2019 14:00\", .format = \"(d|U) (m|UNK) y H:M\") #> [1] \"2019----T14:00\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"changing-reserved-format-characters","dir":"Articles","previous_headings":"","what":"Changing reserved format characters","title":"Converting dates, times or date-times to ISO 8601","text":"might cases reserved characters — \"y\", \"m\", \"d\", \"H\", \"M\", \"S\" — might get way specifying adequate format. example, might tempted use format \"HHMM\" try parse time \"14H00M\". assume first “H” codes parsing hour, second “H” literal “H” , actually, \"HH\" taken mean parsing hours, \"MM\" parse minutes. can use function fmt_cmp() specify alternative format regexps format, replacing default characters. next example, reassign new format strings hour minute components, thus freeing \"H\" \"M\" patterns interpreted hours minutes, taken literally: Note need make sure format component regexps mutually exclusive, .e. don’t overlapping matches; otherwise create_iso8601() fail error. next example months minutes represented \"m\" format resulting ambiguous format specification.","code":"create_iso8601(\"14H00M\", .format = \"HHMM\") #> [1] NA create_iso8601(\"14H00M\", .format = \"xHwM\", .fmt_c = fmt_cmp(hour = \"x\", min = \"w\")) #> [1] \"-----T14:00\" fmt_cmp(hour = \"h\", min = \"m\") #> $sec #> [1] \"S+\" #> #> $min #> [1] \"m\" #> #> $hour #> [1] \"h\" #> #> $mday #> [1] \"d+\" #> #> $mon #> [1] \"m+\" #> #> $year #> [1] \"y+\" #> #> attr(,\"class\") #> [1] \"fmt_c\" try(create_iso8601(\"14H00M\", .format = \"hHmM\", .fmt_c = fmt_cmp(hour = \"h\", min = \"m\"))) #> Error in purrr::map2(dots, .format, ~parse_dttm(dttm = .x, fmt = .y, na = .na, : #> ℹ In index: 1. #> Caused by error in `purrr::map()` at sdtm.oak/R/dtc_parse_dttm.R:104:3: #> ℹ In index: 1. #> Caused by error in `parse_dttm_fmt()` at sdtm.oak/R/parse_dttm_fmt.R:442:3: #> ! Patterns in `fmt_c` have overlapping matches."},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/study_sdtm_spec.html","id":"standards-metadata","dir":"Articles","previous_headings":"","what":"Standards Metadata","title":"All about Metadata","text":"standards metadata used {sdtm.oak} sourced CDISC Library sponsor MDR form documentation standards maintained. metadata provides information following: relationship Data Collection Standards (eCRF & eDT), SDTM mapping, Controlled Terminology Machine-readable standard SDTM mappings Algorithms associated metadata required SDTM automation standards study. upcoming releases {sdtm.oak}, effectively utilize standards metadata customize meet study requirements.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/study_sdtm_spec.html","id":"study-definition-metadata","dir":"Articles","previous_headings":"","what":"Study Definition Metadata","title":"All about Metadata","text":"Study Definition Metadata also referred Study Metadata. Study Definition Metadata provides information eCRF eDT data collected study. eCRF Metadata eCRF Design Metadata fetched EDC system. Metadata includes Forms Metadata: Identifier, eCRF label, Repeating format properties eCRF. Fields Metadata: Identifier, question label, datatype, properties data collection fields study. Data Dictionaries: Identifier controlled terms collected source. Visits: Name visits defined EDC. eDT Metadata eDT Metadata blueprint metadata describes data collected part external data transfer (clinical sites sponsor). includes Dataset name, label, repeating properties, etc. Variable name, datatype, label associated codelist, etc.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/study_sdtm_spec.html","id":"study-sdtm-mappings-metadata-specifications","dir":"Articles","previous_headings":"","what":"Study SDTM Mappings Metadata (specifications)","title":"All about Metadata","text":"Study SDTM mappings metadata study SDTM specification. develop SDTM domains, {sdtm.oak} requires user prepare Study SDTM mappings metadata. Unlike conventional SDTM specification, includes one tab per domain defining target (SDTM domain, Variables) source (raw dataset, raw variables) SDTM mappings, SDTM spec {sdtm.oak} defines source--target relationship. source, SDTM mapping, algorithms, associated metadata defined. table presents columns SDTM mapping specification explanation.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Rammprasad Ganapathy. Author, maintainer. Adam Forys. Author. Edgar Manukyan. Author. Rosemary Li. Author. Preetesh Parikh. Author. Lisa Houterloot. Author. Yogesh Gupta. Author. Omar Garcia. Author. Ramiro Magno. Author. Pattern Institute. Copyright holder, funder. F. Hoffmann-La Roche AG. Copyright holder, funder. Pfizer Inc. Copyright holder, funder.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Ganapathy R, Forys , Manukyan E, Li R, Parikh P, Houterloot L, Gupta Y, Garcia O, Magno R (2024). sdtm.oak: SDTM Data Transformation Engine. R package version 0.0.0.9003, https://github.com/pharmaverse/sdtm.oak, https://pharmaverse.github.io/sdtm.oak/.","code":"@Manual{, title = {sdtm.oak: SDTM Data Transformation Engine}, author = {Rammprasad Ganapathy and Adam Forys and Edgar Manukyan and Rosemary Li and Preetesh Parikh and Lisa Houterloot and Yogesh Gupta and Omar Garcia and Ramiro Magno}, year = {2024}, note = {R package version 0.0.0.9003, https://github.com/pharmaverse/sdtm.oak}, url = {https://pharmaverse.github.io/sdtm.oak/}, }"},{"path":"https://pharmaverse.github.io/sdtm.oak/index.html","id":"sdtmoak-","dir":"","previous_headings":"","what":"SDTM Data Transformation Engine","title":"SDTM Data Transformation Engine","text":"EDC Data Standard agnostic solution enables pharmaceutical programming community develop SDTM datasets R. reusable algorithms concept sdtm.oak provides framework modular programming also can automate SDTM creation based standard SDTM spec.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"SDTM Data Transformation Engine","text":"can install development version sdtm.oak GitHub :","code":"# install.packages(\"remotes\") remotes::install_github(\"pharmaverse/sdtm.oak\")"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":null,"dir":"Reference","previous_headings":"","what":"Add ISO 8601 parsing problems — add_problems","title":"Add ISO 8601 parsing problems — add_problems","text":"add_problems() annotates returned value create_iso8601() possible parsing problems. annotation consists tibble problems, one row parsing failure (see Details section).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add ISO 8601 parsing problems — add_problems","text":"","code":"add_problems(x, is_problem, dtc)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add ISO 8601 parsing problems — add_problems","text":"x character vector date-times ISO 8601 format; typically, output format_iso8601(). is_problem logical indicating date/time inputs associated parsing failures. dtc list character vectors dates, times date-times' components. Typically, parameter takes value passed ... create_iso8601() call.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add ISO 8601 parsing problems — add_problems","text":"Either x without modification, parsing problems exist, annotated x, meaning problems attribute holds parsing issues (see Details section).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add ISO 8601 parsing problems — add_problems","text":"function annotates input x, vector date-times ISO 8601 format, creating attribute named problems. attribute's value tibble parsing problems. problematic date/times indicated logical vector passed argument is_problem. attribute problems returned value contain first column named ..indicates date/time index problematic date/time x, many extra columns inputs (passed dtc). dtc named, names used name extra columns, otherwise get named sequentially like ..var1, ..var2, etc..","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add ISO 8601 parsing problems — add_problems","text":"","code":"date <- c(\"2000-01-05\", \"\", \"1980-06-18\", \"1979-09-07\") time <- c(\"001221\", \"22:35:05\", \"03:00:15\", \"07:09:00\") dtc <- list(date, time) dttm <- c(\"2000-01-05\", \"T22:35:05\", \"1980-06-18T03:00:15\", \"1979-09-07T07:09:00\") is_problem <- c(TRUE, TRUE, FALSE, FALSE) dttm2 <- sdtm.oak:::add_problems(dttm, is_problem, dtc) sdtm.oak:::problems(dttm2) #> # A tibble: 2 × 3 #> ..i ..var1 ..var2 #> #> 1 1 \"2000-01-05\" 001221 #> 2 2 \"\" 22:35:05"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":null,"dir":"Reference","previous_headings":"","what":"Detect problems with the parsing of date/times — any_problems","title":"Detect problems with the parsing of date/times — any_problems","text":"any_problems() takes list capture matrices (see parse_dttm()) reports parsing problems means predicate values. FALSE value indicates parsing successful TRUE value parsing failure least one inputs create_iso8601(). Note internal function used context create_iso8601() source code hence capture matrix corresponds one input create_iso8601().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Detect problems with the parsing of date/times — any_problems","text":"","code":"any_problems(cap_matrices, .cutoff_2000 = 68L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Detect problems with the parsing of date/times — any_problems","text":"cap_matrices list capture matrices sense returned value parse_dttm(). .cutoff_2000 integer value. Two-digit years smaller equal .cutoff_2000 parsed though starting 20, otherwise parsed though starting 19.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Detect problems with the parsing of date/times — any_problems","text":"logical whose length matches number underlying date/times passed inputs create_iso8601(), .e. whose length matches number rows capture matrices cap_matrices.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Detect problems with the parsing of date/times — any_problems","text":"","code":"# No problem (return value is `FALSE`). sdtm.oak:::any_problems(list(sdtm.oak:::parse_dttm(\"1980-06-18\", \"y-m-d\"))) #> [1] FALSE # Now the parsing fails (return value is `TRUE`). sdtm.oak:::any_problems(list(sdtm.oak:::parse_dttm(\"1980-06-18\", \"ymd\"))) #> [1] TRUE # Find if there has been a problem in either in the `date` or `time` inputs. # The following problems are expected with: # - `\"2001/12/25\"` as it won't be parsed with the format `\"y-m-d\"` # - `\"00h12m21\"` as it won't be parsed with the format `\"H:M:S\"`. # date <- c(\"2000-01-05\", \"2001/12/25\", \"1980-06-18\", \"1979-09-07\") time <- c(\"00h12m21\", \"22:35:05\", \"03:00:15\", \"07:09:00\") cap_matrix_date <- sdtm.oak:::parse_dttm(date, \"y-m-d\") cap_matrix_time <- sdtm.oak:::parse_dttm(time, \"H:M:S\") (cap_matrices <- list(cap_matrix_date, cap_matrix_time)) #> [[1]] #> year mon mday hour min sec #> [1,] \"2000\" \"01\" \"05\" NA NA NA #> [2,] NA NA NA NA NA NA #> [3,] \"1980\" \"06\" \"18\" NA NA NA #> [4,] \"1979\" \"09\" \"07\" NA NA NA #> #> [[2]] #> year mon mday hour min sec #> [1,] NA NA NA NA NA NA #> [2,] NA NA NA \"22\" \"35\" \"05\" #> [3,] NA NA NA \"03\" \"00\" \"15\" #> [4,] NA NA NA \"07\" \"09\" \"00\" #> # `any_problems()` returns `TRUE` for the first two elements because of the # failure to parse `\"2001/12/25\"` and `\"00h12m21\"`, respectively. sdtm.oak:::any_problems(cap_matrices) #> [1] TRUE TRUE FALSE FALSE"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert capture matrix — assert_capture_matrix","title":"Assert capture matrix — assert_capture_matrix","text":"assert_capture_matrix() internal helper function aiding checking internal R object contains parsing results returned parse_dttm(): capture matrix. function checks capture matrix matrix contains six columns: year, mon, mday, hour, min sec.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert capture matrix — assert_capture_matrix","text":"","code":"assert_capture_matrix(m)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert capture matrix — assert_capture_matrix","text":"m character matrix.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assert capture matrix — assert_capture_matrix","text":"function throws error m either: character matrix; matrix whose columns (least): year, mon, mday, hour, min sec. Otherwise, returns m invisibly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert capture matrix — assert_capture_matrix","text":"","code":"cols <- c(\"year\", \"mon\", \"mday\", \"hour\", \"min\", \"sec\") m <- matrix(NA_character_, nrow = 1L, ncol = 6L, dimnames = list(NULL, cols)) sdtm.oak:::assert_capture_matrix(m) # These commands should throw an error if (FALSE) { sdtm.oak:::assert_capture_matrix(character()) sdtm.oak:::assert_capture_matrix(matrix(data = NA_character_, nrow = 0, ncol = 0)) sdtm.oak:::assert_capture_matrix(matrix(data = NA_character_, nrow = 1)) }"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert a codelist code — assert_ct_clst","title":"Assert a codelist code — assert_ct_clst","text":"assert_ct_clst() asserts validity codelist code context controlled terminology specification.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert a codelist code — assert_ct_clst","text":"","code":"assert_ct_clst(ct_spec, ct_clst, optional = FALSE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert a codelist code — assert_ct_clst","text":"ct_spec Either data frame encoding controlled terminology data set, NULL. ct_clst string -asserted codelist code, NULL. optional scalar logical, indicating whether ct_clst can NULL .","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assert a codelist code — assert_ct_clst","text":"function throws error ct_clst valid codelist code given controlled terminology data set; otherwise, ct_clst returned invisibly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert a codelist code — assert_ct_clst","text":"","code":"# Load a controlled terminology example. (ct_spec <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # Should work fine. sdtm.oak:::assert_ct_clst(ct_spec = ct_spec, ct_clst = \"C71113\") #> [1] \"C71113\" # In certain cases, you might allow `ct_clst` to be `NULL` as to indicate absence, # in that case, set `optional` to `TRUE` to make `assert_ct_clst()` more # forgiving. sdtm.oak:::assert_ct_clst(ct_spec = ct_spec, ct_clst = NULL, optional = TRUE) # Otherwise it would err. try(sdtm.oak:::assert_ct_clst(ct_spec = ct_spec, ct_clst = NULL, optional = FALSE)) #> Error in sdtm.oak:::assert_ct_clst(ct_spec = ct_spec, ct_clst = NULL, : #> `ct_clst` is a required parameter."},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert a controlled terminology specification — assert_ct_spec","title":"Assert a controlled terminology specification — assert_ct_spec","text":"assert_ct_spec() check whether ct_spec data frame contains variables: codelist_code, collected_value, term_synonyms, term_value. addition, also check data frame empty (rows), whether columns codelist_code term_value contain NA values.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert a controlled terminology specification — assert_ct_spec","text":"","code":"assert_ct_spec(ct_spec, optional = FALSE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert a controlled terminology specification — assert_ct_spec","text":"ct_spec data frame asserted valid controlled terminology data set.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assert a controlled terminology specification — assert_ct_spec","text":"function throws error ct_spec valid controlled terminology data set; otherwise, ct_spec returned invisibly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert a controlled terminology specification — assert_ct_spec","text":"","code":"# If `ct_spec` is a valid controlled terminology then it is returned invisibly. ct_spec_01 <- read_ct_spec_example(\"ct-01-cm\") all.equal(ct_spec_01, sdtm.oak:::assert_ct_spec(ct_spec_01)) #> [1] TRUE # A minimal set of variables needs to be present in `ct_spec` for it to pass the # assertion; `sdtm.oak:::ct_spec_vars()` defines their names. (req_vars <- sdtm.oak:::ct_spec_vars()) #> [1] \"codelist_code\" \"collected_value\" \"term_synonyms\" \"term_value\" # Other (facultative) variables also present in the controlled terminology # example. (opt_vars <- setdiff(colnames(ct_spec_01), req_vars)) #> [1] \"term_code\" \"CodedData\" \"term_preferred_term\" #> [4] \"raw_codelist\" # With only the mandatory variables, the assertion still passes. sdtm.oak:::assert_ct_spec(ct_spec_01[req_vars]) # Not having the required variables results in an error. try(sdtm.oak:::assert_ct_spec(ct_spec_01[opt_vars])) #> Error in sdtm.oak:::assert_ct_spec(ct_spec_01[opt_vars]) : #> Required variables `codelist_code`, `collected_value`, `term_synonyms`, #> and `term_value` are missing in `ct_spec`"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_fmt.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert date time character formats — assert_dtc_fmt","title":"Assert date time character formats — assert_dtc_fmt","text":"assert_dtc_fmt() takes character vector date/time formats checks formats supported, meaning checks one formats listed column fmt dtc_formats, failing error otherwise.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_fmt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert date time character formats — assert_dtc_fmt","text":"","code":"assert_dtc_fmt(fmt)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_fmt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert date time character formats — assert_dtc_fmt","text":"fmt character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_fmt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert date time character formats — assert_dtc_fmt","text":"","code":"sdtm.oak:::assert_dtc_fmt(c(\"ymd\", \"y m d\", \"dmy\", \"HM\", \"H:M:S\", \"y-m-d H:M:S\")) #> [1] \"ymd\" \"y m d\" \"dmy\" \"HM\" \"H:M:S\" #> [6] \"y-m-d H:M:S\" # This example is guarded to avoid throwing errors if (FALSE) { sdtm.oak:::assert_dtc_fmt(\"y years m months d days\") }"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert dtc format — assert_dtc_format","title":"Assert dtc format — assert_dtc_format","text":"assert_dtc_format() internal helper function aiding checking .format parameter create_iso8601().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert dtc format — assert_dtc_format","text":"","code":"assert_dtc_format(.format)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert dtc format — assert_dtc_format","text":".format argument create_iso8601()'s .format parameter.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assert dtc format — assert_dtc_format","text":"function throws error .format either: character vector formats permitted assert_dtc_fmt(); list character vectors formats permitted assert_dtc_fmt(). Otherwise, returns .format invisibly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert dtc format — assert_dtc_format","text":"","code":"sdtm.oak:::assert_dtc_format(\"ymd\") sdtm.oak:::assert_dtc_format(c(\"ymd\", \"y-m-d\")) sdtm.oak:::assert_dtc_format(list(c(\"ymd\", \"y-m-d\"), \"H:M:S\")) # These commands should throw an error if (FALSE) { # Note that `\"year, month, day\"` is not a supported format. sdtm.oak:::assert_dtc_format(\"year, month, day\") }"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an SDTM variable — assign_no_ct","title":"Derive an SDTM variable — assign_no_ct","text":"assign_no_ct() maps variable raw dataset target SDTM variable terminology restrictions. assign_ct() maps variable raw dataset target SDTM variable following controlled terminology recoding.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an SDTM variable — assign_no_ct","text":"","code":"assign_no_ct( raw_dat, raw_var, tgt_var, tgt_dat = NULL, id_vars = oak_id_vars() ) assign_ct( raw_dat, raw_var, tgt_var, ct_spec, ct_clst, tgt_dat = NULL, id_vars = oak_id_vars() )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an SDTM variable — assign_no_ct","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable: single string indicating name raw variable raw_dat. tgt_var target SDTM variable: single string indicating name variable derived. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (raw_dat). ct_spec Study controlled terminology specification: dataframe minimal set columns, see ct_spec_vars() details. ct_clst codelist code indicating subset controlled terminology apply derivation.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an SDTM variable — assign_no_ct","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Derive an SDTM variable — assign_no_ct","text":"","code":"md1 <- tibble::tibble( oak_id = 1:14, raw_source = \"MD1\", patient_number = 101:114, MDIND = c( \"NAUSEA\", \"NAUSEA\", \"ANEMIA\", \"NAUSEA\", \"PYREXIA\", \"VOMITINGS\", \"DIARHHEA\", \"COLD\", \"FEVER\", \"LEG PAIN\", \"FEVER\", \"COLD\", \"COLD\", \"PAIN\" ) ) assign_no_ct( raw_dat = md1, raw_var = \"MDIND\", tgt_var = \"CMINDC\", ) #> # A tibble: 14 × 4 #> oak_id raw_source patient_number CMINDC #> #> 1 1 MD1 101 NAUSEA #> 2 2 MD1 102 NAUSEA #> 3 3 MD1 103 ANEMIA #> 4 4 MD1 104 NAUSEA #> 5 5 MD1 105 PYREXIA #> 6 6 MD1 106 VOMITINGS #> 7 7 MD1 107 DIARHHEA #> 8 8 MD1 108 COLD #> 9 9 MD1 109 FEVER #> 10 10 MD1 110 LEG PAIN #> 11 11 MD1 111 FEVER #> 12 12 MD1 112 COLD #> 13 13 MD1 113 COLD #> 14 14 MD1 114 PAIN cm_inter <- tibble::tibble( oak_id = 1:14, raw_source = \"MD1\", patient_number = 101:114, CMTRT = c( \"BABY ASPIRIN\", \"CORTISPORIN\", \"ASPIRIN\", \"DIPHENHYDRAMINE HCL\", \"PARCETEMOL\", \"VOMIKIND\", \"ZENFLOX OZ\", \"AMITRYPTYLINE\", \"BENADRYL\", \"DIPHENHYDRAMINE HYDROCHLORIDE\", \"TETRACYCLINE\", \"BENADRYL\", \"SOMINEX\", \"ZQUILL\" ), CMROUTE = c( \"ORAL\", \"ORAL\", NA, \"ORAL\", \"ORAL\", \"ORAL\", \"INTRAMUSCULAR\", \"INTRA-ARTERIAL\", NA, \"NON-STANDARD\", \"RANDOM_VALUE\", \"INTRA-ARTICULAR\", \"TRANSDERMAL\", \"OPHTHALMIC\" ) ) # Controlled terminology specification (ct_spec <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist assign_ct( raw_dat = md1, raw_var = \"MDIND\", tgt_var = \"CMINDC\", ct_spec = ct_spec, ct_clst = \"C66729\", tgt_dat = cm_inter ) #> # A tibble: 14 × 6 #> oak_id raw_source patient_number CMTRT CMROUTE CMINDC #> #> 1 1 MD1 101 BABY ASPIRIN ORAL NAUSEA #> 2 2 MD1 102 CORTISPORIN ORAL NAUSEA #> 3 3 MD1 103 ASPIRIN NA ANEMIA #> 4 4 MD1 104 DIPHENHYDRAMINE HCL ORAL NAUSEA #> 5 5 MD1 105 PARCETEMOL ORAL PYREX… #> 6 6 MD1 106 VOMIKIND ORAL VOMIT… #> 7 7 MD1 107 ZENFLOX OZ INTRAM… DIARH… #> 8 8 MD1 108 AMITRYPTYLINE INTRA-… COLD #> 9 9 MD1 109 BENADRYL NA FEVER #> 10 10 MD1 110 DIPHENHYDRAMINE HYDROCHLORIDE NON-ST… LEG P… #> 11 11 MD1 111 TETRACYCLINE RANDOM… FEVER #> 12 12 MD1 112 BENADRYL INTRA-… COLD #> 13 13 MD1 113 SOMINEX TRANSD… COLD #> 14 14 MD1 114 ZQUILL OPHTHA… PAIN"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an ISO8601 date-time variable — assign_datetime","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"assign_datetime() maps one variables date/time components raw dataset target SDTM variable following ISO8601 format.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"","code":"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 )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable(s): character vector indicating name(s) raw variable(s) raw_dat date time components parsed ISO8601 format variable tgt_var. raw_fmt date/time parsing format. Either character vector list character vectors. character vector passed element taken parsing format variable indicated raw_var. list provided, element must character vector formats. first vector formats used parsing first variable raw_var, . tgt_var target SDTM variable: single string indicating name variable derived. raw_unk character vector string literals regarded missing values parsing. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (raw_dat). .warn Whether warn parsing failures.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"","code":"# `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 #> #> 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 #> #> 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 #> #> 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 #> #> 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 #> #> 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 #> #> 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"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/clear_cache.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear {sdtm.oak} cache of memoised functions — clear_cache","title":"Clear {sdtm.oak} cache of memoised functions — clear_cache","text":"{sdtm.oak} functions results cached runtime efficiency. Use function reset cache. Memoised functions: ct_mappings()","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/clear_cache.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear {sdtm.oak} cache of memoised functions — clear_cache","text":"","code":"clear_cache()"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/clear_cache.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear {sdtm.oak} cache of memoised functions — clear_cache","text":"Returns logical value, indicating whether resetting cache successful (TRUE) (FALSE).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/clear_cache.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Clear {sdtm.oak} cache of memoised functions — clear_cache","text":"","code":"clear_cache() #> [1] TRUE"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":null,"dir":"Reference","previous_headings":"","what":"Coalesce capture matrices — coalesce_capture_matrices","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"coalesce_capture_matrices() combines several capture matrices one. argument ... capture matrix sense output complete_capture_matrix(), meaning character matrix six columns whose names : year, mon, mday, hour, min sec.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"","code":"coalesce_capture_matrices(...)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"... sequence capture matrices.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"single capture matrix whose values coalesced sense coalesce().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"","code":"cols <- c(\"year\", \"mon\", \"mday\", \"hour\", \"min\", \"sec\") dates <- c(\"2020\", \"01\", \"01\", \"20\", NA, NA) times <- c(NA, NA, NA, \"10\", \"00\", \"05\") m_dates <- matrix(dates, nrow = 1L, ncol = 6L, dimnames = list(NULL, cols)) m_times <- matrix(times, nrow = 1L, ncol = 6L, dimnames = list(NULL, cols)) # Note how the hour \"20\" takes precedence over \"10\" sdtm.oak:::coalesce_capture_matrices(m_dates, m_times) #> year mon mday hour min sec #> [1,] \"2020\" \"01\" \"01\" \"20\" \"00\" \"05\" # Reverse the order of the inputs and now hour \"10\" takes precedence sdtm.oak:::coalesce_capture_matrices(m_times, m_dates) #> year mon mday hour min sec #> [1,] \"2020\" \"01\" \"01\" \"10\" \"00\" \"05\" # Single inputs should result in the same output as the input sdtm.oak:::coalesce_capture_matrices(m_dates) #> year mon mday hour min sec #> [1,] \"2020\" \"01\" \"01\" \"20\" NA NA sdtm.oak:::coalesce_capture_matrices(m_times) #> year mon mday hour min sec #> [1,] NA NA NA \"10\" \"00\" \"05\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Complete a capture matrix — complete_capture_matrix","title":"Complete a capture matrix — complete_capture_matrix","text":"complete_capture_matrix() completes missing, , columns capture matrix.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Complete a capture matrix — complete_capture_matrix","text":"","code":"complete_capture_matrix(m)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Complete a capture matrix — complete_capture_matrix","text":"m character matrix might missing one following columns: year, mon, mday, hour, min sec.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Complete a capture matrix — complete_capture_matrix","text":"character matrix contains columns year, mon, mday, hour, min sec. existing columns dropped.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Complete a capture matrix — complete_capture_matrix","text":"","code":"sdtm.oak:::complete_capture_matrix(matrix(data = NA_character_, nrow = 0, ncol = 0)) sdtm.oak:::complete_capture_matrix(matrix(data = NA_character_, nrow = 1)) # m <- matrix(NA_character_, nrow = 1, ncol = 2, dimnames = list(NULL, c(\"year\", \"sec\"))) # sdtm.oak:::complete_capture_matrix(m) # m <- matrix(c(\"2020\", \"10\"), nrow = 1, ncol = 2, dimnames = list(NULL, c(\"year\", \"sec\"))) # sdtm.oak:::complete_capture_matrix(m) # Any other existing columns are dropped. # m <- matrix(c(\"2020\", \"10\"), nrow = 1, ncol = 2, dimnames = list(NULL, c(\"semester\", \"quarter\"))) # sdtm.oak:::complete_capture_matrix(m)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"contains_oak_id_vars() evaluates whether character vector x contains raw dataset key variable names, .e. called Oak identifier variables --- defined return value oak_id_vars().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"","code":"contains_oak_id_vars(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"logical scalar value.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"","code":"# `oak_id_vars()` is the function that defines what are the minimal set of # oak keys. Hence, by definition, the following code should always return # `TRUE`. sdtm.oak:::contains_oak_id_vars(sdtm.oak:::oak_id_vars()) #> [1] TRUE # Returns `FALSE`. sdtm.oak:::contains_oak_id_vars(character()) #> [1] FALSE # Another example that returns `FALSE` because it is missing # `\"patient_number\"`. sdtm.oak:::contains_oak_id_vars(c(\"oak_id\", \"raw_source\")) #> [1] FALSE"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/create_iso8601.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert date or time collected values to ISO 8601 — create_iso8601","title":"Convert date or time collected values to ISO 8601 — create_iso8601","text":"create_iso8601() converts vectors dates, times date-times ISO 8601 format. Learn vignette(\"iso_8601\").","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/create_iso8601.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert date or time collected values to ISO 8601 — create_iso8601","text":"","code":"create_iso8601( ..., .format, .fmt_c = fmt_cmp(), .na = NULL, .cutoff_2000 = 68L, .check_format = FALSE, .warn = TRUE )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/create_iso8601.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert date or time collected values to ISO 8601 — create_iso8601","text":"... Character vectors dates, times date-times' components. .format Parsing format(s). Either character vector list character vectors. character vector passed element taken parsing format vector passed .... list provided, element must character vector formats. first vector formats used parsing first vector passed ..., . .fmt_c list regexps use parsing .format. Use fmt_cmp() create object pass argument parameter. .na character vector string literals regarded missing values parsing. .cutoff_2000 integer value. Two-digit years smaller equal .cutoff_2000 parsed though starting 20, otherwise parsed though starting 19. .check_format Whether check formats passed .format, meaning check selection validated formats dtc_formats; permissible interpretation formats. .warn Whether warn parsing failures.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/create_iso8601.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert date or time collected values to ISO 8601 — create_iso8601","text":"","code":"# Converting dates create_iso8601(c(\"2020-01-01\", \"20200102\"), .format = \"y-m-d\") #> [1] \"2020-01-01\" NA create_iso8601(c(\"2020-01-01\", \"20200102\"), .format = \"ymd\") #> [1] NA \"2020-01-02\" create_iso8601(c(\"2020-01-01\", \"20200102\"), .format = list(c(\"y-m-d\", \"ymd\"))) #> [1] \"2020-01-01\" \"2020-01-02\" # Two-digit years are supported create_iso8601(c(\"20-01-01\", \"200101\"), .format = list(c(\"y-m-d\", \"ymd\"))) #> [1] \"2020-01-01\" \"2020-01-01\" # `.cutoff_2000` sets the cutoff for two-digit to four-digit year conversion # Default is at 68. create_iso8601(c(\"67-01-01\", \"68-01-01\", \"69-01-01\"), .format = \"y-m-d\") #> [1] \"2067-01-01\" \"2068-01-01\" \"1969-01-01\" # Change it to 80. create_iso8601(c(\"79-01-01\", \"80-01-01\", \"81-01-01\"), .format = \"y-m-d\", .cutoff_2000 = 80) #> [1] \"2079-01-01\" \"2080-01-01\" \"1981-01-01\" # Converting times create_iso8601(\"15:10\", .format = \"HH:MM\") #> [1] \"-----T15:10\" create_iso8601(\"2:10\", .format = \"HH:MM\") #> [1] \"-----T02:10\" create_iso8601(\"2:1\", .format = \"HH:MM\") #> [1] \"-----T02:01\" create_iso8601(\"02:01:56\", .format = \"HH:MM:SS\") #> [1] \"-----T02:01:56\" create_iso8601(\"020156.5\", .format = \"HHMMSS\") #> [1] \"-----T02:01:56.5\" # Converting date-times create_iso8601(\"12 NOV 202015:15\", .format = \"dd mmm yyyyHH:MM\") #> [1] \"2020-11-12T15:15\" # Indicate allowed missing values to make the parsing pass create_iso8601(\"U DEC 201914:00\", .format = \"dd mmm yyyyHH:MM\") #> [1] NA create_iso8601(\"U DEC 201914:00\", .format = \"dd mmm yyyyHH:MM\", .na = \"U\") #> [1] \"2019-12--T14:00\" create_iso8601(\"NOV 2020\", .format = \"m y\") #> [1] \"2020-11\" create_iso8601(c(\"MAR 2019\", \"MaR 2020\", \"mar 2021\"), .format = \"m y\") #> [1] \"2019-03\" \"2020-03\" \"2021-03\" create_iso8601(\"2019-04-041045-\", .format = \"yyyy-mm-ddHHMM-\") #> [1] \"2019-04-04T10:45\" create_iso8601(\"20200507null\", .format = \"ymd(HH:MM:SS)\") #> [1] NA create_iso8601(\"20200507null\", .format = \"ymd((HH:MM:SS)|null)\") #> [1] \"2020-05-07\" # Fractional seconds create_iso8601(\"2019-120602:20:13.1230001\", .format = \"y-mdH:M:S\") #> [1] \"2019-12-06T02:20:13.1230001\" # Use different reserved characters in the format specification # Here we change \"H\" to \"x\" and \"M\" to \"w\", for hour and minute, respectively. create_iso8601(\"14H00M\", .format = \"HHMM\") #> [1] NA create_iso8601(\"14H00M\", .format = \"xHwM\", .fmt_c = fmt_cmp(hour = \"x\", min = \"w\")) #> [1] \"-----T14:00\" # Alternative formats with unknown values datetimes <- c(\"UN UNK 201914:00\", \"UN JAN 2021\") format <- list(c(\"dd mmm yyyy\", \"dd mmm yyyyHH:MM\")) create_iso8601(datetimes, .format = format, .na = c(\"UN\", \"UNK\")) #> [1] \"2019----T14:00\" \"2021-01\" # Dates and times may come in many format variations fmt <- \"dd MMM yyyy HH nn ss\" fmt_cmp <- fmt_cmp(mon = \"MMM\", min = \"nn\", sec = \"ss\") create_iso8601(\"05 feb 1985 12 55 02\", .format = fmt, .fmt_c = fmt_cmp) #> [1] \"1985-02-05T12:55:02\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":null,"dir":"Reference","previous_headings":"","what":"Recode according to controlled terminology — ct_map","title":"Recode according to controlled terminology — ct_map","text":"ct_map() recodes vector following controlled terminology.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Recode according to controlled terminology — ct_map","text":"","code":"ct_map( x, ct_spec = NULL, ct_clst = NULL, from = ct_spec_vars(\"from\"), to = ct_spec_vars(\"to\") )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Recode according to controlled terminology — ct_map","text":"x character vector terms recoded following controlled terminology. ct_spec tibble providing controlled terminology specification. ct_clst character vector indicating set possible controlled terminology codelists codes used recoding. default (NULL) codelists available ct_spec used. character vector column names indicating variables containing values matched terminology recoding. single string indicating column whose values recoded .","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Recode according to controlled terminology — ct_map","text":"character vector terminology recoded values x. match found controlled terminology spec provided ct_spec, x values returned uppercase. ct_spec provided x returned unchanged.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Recode according to controlled terminology — ct_map","text":"","code":"# A few example terms. terms <- c( \"/day\", \"Yes\", \"Unknown\", \"Prior\", \"Every 2 hours\", \"Percentage\", \"International Unit\" ) # Load a controlled terminology example (ct_spec <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # Use all possible matching terms in the controlled terminology. ct_map(x = terms, ct_spec = ct_spec) #> [1] \"QD\" \"Y\" \"UNKNOWN\" \"BEFORE\" \"Q2H\" \"%\" \"IU\" # Note that if the controlled terminology mapping is restricted to a codelist # code, e.g. C71113, then only `\"/day\"` and `\"Every 2 hours\"` get mapped to # `\"QD\"` and `\"Q2H\"`, respectively; remaining terms won't match given the # codelist code # restriction, and will be mapped to an uppercase version of # the original terms. ct_map(x = terms, ct_spec = ct_spec, ct_clst = \"C71113\") #> [1] \"QD\" \"YES\" \"UNKNOWN\" #> [4] \"PRIOR\" \"Q2H\" \"PERCENTAGE\" #> [7] \"INTERNATIONAL UNIT\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":null,"dir":"Reference","previous_headings":"","what":"Controlled terminology mappings — ct_mappings","title":"Controlled terminology mappings — ct_mappings","text":"ct_mappings() takes controlled terminology specification returns mappings form tibble long format, .e. recoding values column column values, one mapping per row. resulting mappings unique, .e. values duplicated two columns, first column indicated takes precedence, mapping retained controlled terminology map.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Controlled terminology mappings — ct_mappings","text":"","code":"ct_mappings(ct_spec, from = ct_spec_vars(\"from\"), to = ct_spec_vars(\"to\"))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Controlled terminology mappings — ct_mappings","text":"ct_spec Controlled terminology specification tibble. row mapped controlled term. Controlled terms expected column indicated to_col. character vector column names indicating variables containing values recoded. single string indicating column whose values recoded .","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Controlled terminology mappings — ct_mappings","text":"tibble two columns, , indicating mapping values, one per row.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Controlled terminology mappings — ct_mappings","text":"","code":"# Read in a bundled controlled terminology spec example (ex. 01). (ct_spec_01 <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # Generate mappings from the terminology specification. sdtm.oak:::ct_mappings(ct_spec = ct_spec_01) #> # A tibble: 79 × 2 #> from to #> #> 1 QD QD #> 2 BID BID #> 3 PRN PRN #> 4 Q2H Q2H #> 5 QID QID #> 6 CAPSULE CAPSULE #> 7 PILL PILL #> 8 LOTION LOTION #> 9 AEROSOL AEROSOL #> 10 INHALANT INHALANT #> # ℹ 69 more rows # Take a glimpse at those mappings where an actual recoding happens. sdtm.oak:::ct_mappings(ct_spec = ct_spec_01) |> dplyr::filter(from != to) |> print(n = 20) #> # A tibble: 49 × 2 #> from to #> #> 1 QD (Every Day) QD #> 2 BID (Twice a Day) BID #> 3 PRN (As Needed) PRN #> 4 Q2H (Every 2 Hours) Q2H #> 5 QID (4 Times a Day) QID #> 6 Capsule CAPSULE #> 7 Pill PILL #> 8 Lotion LOTION #> 9 Aerosol AEROSOL #> 10 Inhalant INHALANT #> 11 Injection INJECTION #> 12 Liquid LIQUID #> 13 Tablet TABLET #> 14 Yes Y #> 15 IM (Intramuscular) INTRAMUSCULAR #> 16 EP (Epidural) EPIDURAL #> 17 IA (Intra-arterial) INTRA-ARTERIAL #> 18 IJ (Intra-articular) INTRA-ARTICULAR #> 19 OP (Ophthalmic) OPHTHALMIC #> 20 PO (Oral) ORAL #> # ℹ 29 more rows"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":null,"dir":"Reference","previous_headings":"","what":"Find the path to an example controlled terminology file — ct_spec_example","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"ct_spec_example() resolves local path example controlled terminology file.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"","code":"ct_spec_example(example)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"example string either basename, file name, relative path controlled terminology file bundled {stdm.oak}, see examples.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"local path example file example supplied, character vector example file names.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"","code":"# Get the local path to controlled terminology example file 01 # Using the basename only: ct_spec_example(\"ct-01-cm\") #> [1] \"/renv/lib/R-4.3/x86_64-pc-linux-gnu/sdtm.oak/ct/ct-01-cm.csv\" # Using the file name: ct_spec_example(\"ct-01-cm.csv\") #> [1] \"/renv/lib/R-4.3/x86_64-pc-linux-gnu/sdtm.oak/ct/ct-01-cm.csv\" # Using the relative path: ct_spec_example(\"ct/ct-01-cm.csv\") #> [1] \"/renv/lib/R-4.3/x86_64-pc-linux-gnu/sdtm.oak/ct/ct-01-cm.csv\" # If no example is provided it returns a vector of possible choices. ct_spec_example() #> [1] \"ct-01-cm.csv\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Controlled terminology variables — ct_spec_vars","title":"Controlled terminology variables — ct_spec_vars","text":"ct_spec_vars() returns mandatory variables present data set representing controlled terminology. default, returns required variables. subset variables used matching terms needed, request subset variables passing argument value \"\". mapping-variable requested, simply pass \"\". codelist code variable name needed pass \"ct_clst\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Controlled terminology variables — ct_spec_vars","text":"","code":"ct_spec_vars(set = c(\"all\", \"ct_clst\", \"from\", \"to\"))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Controlled terminology variables — ct_spec_vars","text":"set scalar character (string), one : \"\" (default), \"ct_clst\", \"\" \"\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_vars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Controlled terminology variables — ct_spec_vars","text":"","code":"# These two calls are equivalent and return all required variables in a # controlled terminology data set. ct_spec_vars() #> [1] \"codelist_code\" \"collected_value\" \"term_synonyms\" \"term_value\" ct_spec_vars(\"all\") #> [1] \"codelist_code\" \"collected_value\" \"term_synonyms\" \"term_value\" # \"Codelist code\" variable name. ct_spec_vars(\"ct_clst\") #> [1] \"codelist_code\" # \"From\" variables ct_spec_vars(\"from\") #> [1] \"collected_value\" \"term_synonyms\" # The \"to\" variable. ct_spec_vars(\"to\") #> [1] \"term_value\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":null,"dir":"Reference","previous_headings":"","what":"derive_study_day performs study day calculation — derive_study_day","title":"derive_study_day performs study day calculation — derive_study_day","text":"function takes input data frame reference data frame (DM domain cases), calculate study day reference date target date. case unexpected conditions like reference date unique patient, reference input dates actual dates, NA returned records.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"derive_study_day performs study day calculation — derive_study_day","text":"","code":"derive_study_day( sdtm_in, dm_domain, tgdt, refdt, study_day_var, merge_key = \"USUBJID\" )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"derive_study_day performs study day calculation — derive_study_day","text":"sdtm_in Input data frame contains target date. dm_domain Reference date frame contains reference date. tgdt Target date sdtm_in used calculate study day. refdt Reference date dm_domain used reference calculate study day. study_day_var New study day variable name output. example, AESTDY AE domain CMSTDY CM domain. merge_key Character represent merging key sdtm_in dm_domain.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"derive_study_day performs study day calculation — derive_study_day","text":"Data frame takes columns sdtm_in new variable represent calculated study day.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"derive_study_day performs study day calculation — derive_study_day","text":"","code":"ae <- data.frame( USUBJID = c(\"study123-123\", \"study123-124\", \"study123-125\"), AESTDTC = c(\"2012-01-01\", \"2012-04-14\", \"2012-04-14\") ) dm <- data.frame( USUBJID = c(\"study123-123\", \"study123-124\", \"study123-125\"), RFSTDTC = c(\"2012-02-01\", \"2012-04-14\", NA) ) ae$AESTDTC <- as.Date(ae$AESTDTC) dm$RFSTDTC <- as.Date(dm$RFSTDTC) derive_study_day(ae, dm, \"AESTDTC\", \"RFSTDTC\", \"AESTDY\") #> USUBJID AESTDTC AESTDY #> 1 study123-123 2012-01-01 -31 #> 2 study123-124 2012-04-14 1 #> 3 study123-125 2012-04-14 NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dtc_formats.html","id":null,"dir":"Reference","previous_headings":"","what":"Date/time collection formats — dtc_formats","title":"Date/time collection formats — dtc_formats","text":"Date/time collection formats","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dtc_formats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Date/time collection formats — dtc_formats","text":"","code":"dtc_formats"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dtc_formats.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Date/time collection formats — dtc_formats","text":"tibble 20 formats three variables: fmt Format string. type Whether date, time date-time. description Description date-time components parsed.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dtc_formats.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Date/time collection formats — dtc_formats","text":"","code":"dtc_formats #> # A tibble: 20 × 3 #> fmt type description #> #> 1 ymd date Parses a date: year, month, and month day. #> 2 y m d date Parses a date: year, month, and month day. #> 3 y-m-d date Parses a date: year, month, and month day. #> 4 dmy date Parses a date: month day, month and year. #> 5 d m y date Parses a date: month day, month and year. #> 6 d-m-y date Parses a date: month day, month and year. #> 7 ym date Parses a date: year and month. #> 8 y m date Parses a date: year and month. #> 9 y-m date Parses a date: year and month. #> 10 my date Parses a date: month and year. #> 11 m y date Parses a date: month and year. #> 12 m-y date Parses a date: month and year. #> 13 HM time Parses a time: hour and minutes. #> 14 HMS time Parses a time: hour, minutes, and seconds. #> 15 H:M time Parses a time: hour and minutes. #> 16 H:M:S time Parses a time: hour, minutes and seconds. #> 17 ymdH:M:S datetime Parses a date-time: year, month, month day, hour, minut… #> 18 ymd H:M:S datetime Parses a date-time: year, month, month day, hour, minut… #> 19 y-m-d H:M:S datetime Parses a date-time: year, month, month day, hour, minut… #> 20 y m d H:M:S datetime Parses a date-time: year, month, month day, hour, minut…"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"dttm_fmt_to_regex() takes tibble parsed date/time format components (returned parse_dttm_fmt()), mapping date/time component formats regexps generates single regular expression groups matching date/time components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"","code":"dttm_fmt_to_regex( fmt, fmt_regex = fmt_rg(), fmt_c = fmt_cmp(), anchored = TRUE )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"fmt format string (scalar) parsed patterns. fmt_regex named character vector regexps, one date/time component. anchored Whether final regex anchored, .e. bounded \"^\" \"$\" whole match.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"string containing regular expression matching date/time components according format.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"","code":"sdtm.oak:::dttm_fmt_to_regex(\"y\") #> ^(?(\\d{2})?\\d{2})$ sdtm.oak:::dttm_fmt_to_regex(\"y\", anchored = FALSE) #> [1] \"(?(\\\\d{2})?\\\\d{2})\" sdtm.oak:::dttm_fmt_to_regex(\"m\") #> ^(?\\d\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])$ sdtm.oak:::dttm_fmt_to_regex(\"ymd\") #> ^(?(\\d{2})?\\d{2})(?\\d\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])(?\\b\\d|\\d{2})$ sdtm.oak:::dttm_fmt_to_regex(\"ymd HH:MM:SS\") #> ^(?(\\d{2})?\\d{2})(?\\d\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])(?\\b\\d|\\d{2}) (?\\d?\\d):(?(\\b\\d|\\d{2})):(?(\\b\\d|\\d{2})(\\.\\d*)?)$"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/find_int_gap.html","id":null,"dir":"Reference","previous_headings":"","what":"Find gap intervals in integer sequences — find_int_gap","title":"Find gap intervals in integer sequences — find_int_gap","text":"find_int_gap() determines start end positions gap intervals sequence integers. default, interval range look gaps defined minimum maximum values x; specify xmin xmax change range explicitly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/find_int_gap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Find gap intervals in integer sequences — find_int_gap","text":"","code":"find_int_gap(x, xmin = min(x), xmax = max(x))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/find_int_gap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Find gap intervals in integer sequences — find_int_gap","text":"x integer vector. xmin Left endpoint integer value. xmax Right endpoint integer value.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/find_int_gap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Find gap intervals in integer sequences — find_int_gap","text":"tibble gap intervals two columns: start: left endpoint end: right endpoint gap intervals found empty tibble returned.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":null,"dir":"Reference","previous_headings":"","what":"Regexps for date/time format components — fmt_cmp","title":"Regexps for date/time format components — fmt_cmp","text":"fmt_cmp() creates character vector patterns match individual format date/time components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regexps for date/time format components — fmt_cmp","text":"","code":"fmt_cmp( sec = \"S+\", min = \"M+\", hour = \"H+\", mday = \"d+\", mon = \"m+\", year = \"y+\" )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regexps for date/time format components — fmt_cmp","text":"sec string pattern matching second format component. min string pattern matching minute format component. hour string pattern matching hour format component. mday string pattern matching month day format component. mon string pattern matching month format component. year string pattern matching year format component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regexps for date/time format components — fmt_cmp","text":"named character vector date/time format patterns. vector six elements, one date/time component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Regexps for date/time format components — fmt_cmp","text":"","code":"# Regexps to parse format components fmt_cmp() #> $sec #> [1] \"S+\" #> #> $min #> [1] \"M+\" #> #> $hour #> [1] \"H+\" #> #> $mday #> [1] \"d+\" #> #> $mon #> [1] \"m+\" #> #> $year #> [1] \"y+\" #> #> attr(,\"class\") #> [1] \"fmt_c\" fmt_cmp(year = \"yyyy\") #> $sec #> [1] \"S+\" #> #> $min #> [1] \"M+\" #> #> $hour #> [1] \"H+\" #> #> $mday #> [1] \"d+\" #> #> $mon #> [1] \"m+\" #> #> $year #> [1] \"yyyy\" #> #> attr(,\"class\") #> [1] \"fmt_c\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":null,"dir":"Reference","previous_headings":"","what":"Regexps for date/time components — fmt_rg","title":"Regexps for date/time components — fmt_rg","text":"fmt_rg() creates character vector named patterns match individual date/time components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regexps for date/time components — fmt_rg","text":"","code":"fmt_rg( sec = \"(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?\", min = \"(\\\\b\\\\d|\\\\d{2})\", hour = \"\\\\d?\\\\d\", mday = \"\\\\b\\\\d|\\\\d{2}\", mon = stringr::str_glue(\"\\\\d\\\\d|{months_abb_regex()}\"), year = \"(\\\\d{2})?\\\\d{2}\", na = NULL, sec_na = na, min_na = na, hour_na = na, mday_na = na, mon_na = na, year_na = na )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regexps for date/time components — fmt_rg","text":"sec Regexp second component. min Regexp minute component. hour Regexp hour component. mday Regexp month day component. mon Regexp month component. year Regexp year component. na Regexp alternatives, useful match special values coding missingness. sec_na na specifically second component. min_na na specifically minute component. hour_na na specifically hour component. mday_na na specifically month day component. mon_na na specifically month component. year_na na specifically year component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regexps for date/time components — fmt_rg","text":"named character vector named patterns (regexps) matching date/time component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Regexps for date/time components — fmt_rg","text":"","code":"# Default regexps sdtm.oak:::fmt_rg() #> sec #> \"(?(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?)\" #> min #> \"(?(\\\\b\\\\d|\\\\d{2}))\" #> hour #> \"(?\\\\d?\\\\d)\" #> mday #> \"(?\\\\b\\\\d|\\\\d{2})\" #> mon #> \"(?\\\\d\\\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])\" #> year #> \"(?(\\\\d{2})?\\\\d{2})\" # You may change the way months are matched, e.g. you might not want to match # month abbreviations, i.e. only numerical months. So pass an explicit regex # for numerical months: sdtm.oak:::fmt_rg(mon = r\"[\\b\\d|\\d{2}]\") #> sec min #> \"(?(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?)\" \"(?(\\\\b\\\\d|\\\\d{2}))\" #> hour mday #> \"(?\\\\d?\\\\d)\" \"(?\\\\b\\\\d|\\\\d{2})\" #> mon year #> \"(?\\\\b\\\\d|\\\\d{2})\" \"(?(\\\\d{2})?\\\\d{2})\" # Make date/time components accept `\"UNK\"` as a possible pattern (useful # to match funny codes for `NA`). sdtm.oak:::fmt_rg(na = \"UNK\") #> sec #> \"(?(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?|UNK)\" #> min #> \"(?(\\\\b\\\\d|\\\\d{2})|UNK)\" #> hour #> \"(?\\\\d?\\\\d|UNK)\" #> mday #> \"(?\\\\b\\\\d|\\\\d{2}|UNK)\" #> mon #> \"(?\\\\d\\\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc]|UNK)\" #> year #> \"(?(\\\\d{2})?\\\\d{2}|UNK)\" # Or be more specific and use `\"UNK\"` for the year component only. sdtm.oak:::fmt_rg(year_na = \"UNK\") #> sec #> \"(?(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?)\" #> min #> \"(?(\\\\b\\\\d|\\\\d{2}))\" #> hour #> \"(?\\\\d?\\\\d)\" #> mday #> \"(?\\\\b\\\\d|\\\\d{2})\" #> mon #> \"(?\\\\d\\\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])\" #> year #> \"(?(\\\\d{2})?\\\\d{2}|UNK)\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert date/time components into ISO8601 format — format_iso8601","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"format_iso8601() takes character matrix date/time components converts component ISO8601 format. practice entails converting years four digit number, month, day, hours, minutes seconds two-digit numbers. available (NA) components converted \"-\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"","code":"format_iso8601(m, .cutoff_2000 = 68L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"m character matrix date/time components. must six named columns: year, mon, mday, hour, min sec. .cutoff_2000 integer value. Two-digit years smaller equal .cutoff_2000 parsed though starting 20, otherwise parsed though starting 19.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"character vector date-times following ISO8601 format.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"","code":"cols <- c(\"year\", \"mon\", \"mday\", \"hour\", \"min\", \"sec\") m <- matrix( c( \"99\", \"00\", \"01\", \"Jan\", \"feb\", \"03\", \"1\", \"01\", \"31\", \"00\", \"12\", \"23\", \"00\", \"59\", \"10\", \"42\", \"5.15\", NA ), ncol = 6, dimnames = list(c(), cols) ) sdtm.oak:::format_iso8601(m) #> [1] \"1999-01-01T00:00:42\" \"2000-02-01T12:59:05.15\" \"2001-03-31T23:10\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an SDTM variable with a hardcoded value — harcode","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"hardcode_no_ct() maps hardcoded value target SDTM variable terminology restrictions. hardcode_ct() maps hardcoded value target SDTM variable controlled terminology recoding.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"","code":"hardcode_no_ct( raw_dat, raw_var, tgt_var, tgt_val, tgt_dat = NULL, id_vars = oak_id_vars() ) hardcode_ct( raw_dat, raw_var, tgt_var, tgt_val, ct_spec, ct_clst, tgt_dat = NULL, id_vars = oak_id_vars() )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable: single string indicating name raw variable raw_dat. tgt_var target SDTM variable: single string indicating name variable derived. tgt_val target SDTM value hardcoded variable indicated tgt_var. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (raw_dat). ct_spec Study controlled terminology specification: dataframe minimal set columns, see ct_spec_vars() details. parameter optional, left NULL controlled terminology recoding applied. ct_clst codelist code indicating subset controlled terminology apply derivation. parameter optional, left NULL, possible recodings ct_spec attempted.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"","code":"md1 <- tibble::tribble( ~oak_id, ~raw_source, ~patient_number, ~MDRAW, 1L, \"MD1\", 101L, \"BABY ASPIRIN\", 2L, \"MD1\", 102L, \"CORTISPORIN\", 3L, \"MD1\", 103L, NA_character_, 4L, \"MD1\", 104L, \"DIPHENHYDRAMINE HCL\" ) # Derive a new variable `CMCAT` by overwriting `MDRAW` with the # hardcoded value \"GENERAL CONCOMITANT MEDICATIONS\". hardcode_no_ct( raw_dat = md1, raw_var = \"MDRAW\", tgt_var = \"CMCAT\", tgt_val = \"GENERAL CONCOMITANT MEDICATIONS\" ) #> # A tibble: 4 × 4 #> oak_id raw_source patient_number CMCAT #> #> 1 1 MD1 101 GENERAL CONCOMITANT MEDICATIONS #> 2 2 MD1 102 GENERAL CONCOMITANT MEDICATIONS #> 3 3 MD1 103 NA #> 4 4 MD1 104 GENERAL CONCOMITANT MEDICATIONS cm_inter <- tibble::tribble( ~oak_id, ~raw_source, ~patient_number, ~CMTRT, ~CMINDC, 1L, \"MD1\", 101L, \"BABY ASPIRIN\", NA, 2L, \"MD1\", 102L, \"CORTISPORIN\", \"NAUSEA\", 3L, \"MD1\", 103L, \"ASPIRIN\", \"ANEMIA\", 4L, \"MD1\", 104L, \"DIPHENHYDRAMINE HCL\", \"NAUSEA\", 5L, \"MD1\", 105L, \"PARACETAMOL\", \"PYREXIA\" ) # Derive a new variable `CMCAT` by overwriting `MDRAW` with the # hardcoded value \"GENERAL CONCOMITANT MEDICATIONS\" with a prior join to # `target_dataset`. hardcode_no_ct( raw_dat = md1, raw_var = \"MDRAW\", tgt_var = \"CMCAT\", tgt_val = \"GENERAL CONCOMITANT MEDICATIONS\", tgt_dat = cm_inter ) #> # A tibble: 5 × 6 #> oak_id raw_source patient_number CMTRT CMINDC CMCAT #> #> 1 1 MD1 101 BABY ASPIRIN NA GENERAL CONCOMIT… #> 2 2 MD1 102 CORTISPORIN NAUSEA GENERAL CONCOMIT… #> 3 3 MD1 103 ASPIRIN ANEMIA NA #> 4 4 MD1 104 DIPHENHYDRAMINE HCL NAUSEA GENERAL CONCOMIT… #> 5 5 MD1 105 PARACETAMOL PYREXIA NA # Controlled terminology specification (ct_spec <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # Hardcoding of `CMCAT` with the value `\"GENERAL CONCOMITANT MEDICATIONS\"` # involving terminology recoding. `NA` values in `MDRAW` are preserved in # `CMCAT`. hardcode_ct( raw_dat = md1, raw_var = \"MDRAW\", tgt_var = \"CMCAT\", tgt_val = \"GENERAL CONCOMITANT MEDICATIONS\", ct_spec = ct_spec, ct_clst = \"C66729\", tgt_dat = cm_inter ) #> # A tibble: 5 × 6 #> oak_id raw_source patient_number CMTRT CMINDC CMCAT #> #> 1 1 MD1 101 BABY ASPIRIN NA GENERAL CONCOMIT… #> 2 2 MD1 102 CORTISPORIN NAUSEA GENERAL CONCOMIT… #> 3 3 MD1 103 ASPIRIN ANEMIA NA #> 4 4 MD1 104 DIPHENHYDRAMINE HCL NAUSEA GENERAL CONCOMIT… #> 5 5 MD1 105 PARACETAMOL PYREXIA NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":null,"dir":"Reference","previous_headings":"","what":"Determine Indices for Recoding — index_for_recode","title":"Determine Indices for Recoding — index_for_recode","text":"index_for_recode() identifies positions elements x match values specified vector. function primarily used facilitate recoding values pinpointing elements x correspond values thus need replaced updated.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Determine Indices for Recoding — index_for_recode","text":"","code":"index_for_recode(x, from)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Determine Indices for Recoding — index_for_recode","text":"x vector values search matches. vector values match elements x.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Determine Indices for Recoding — index_for_recode","text":"integer vector length x, containing indices matched values vector. element x match value , corresponding position output NA. index information critical subsequent recoding operations.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Determine Indices for Recoding — index_for_recode","text":"","code":"sdtm.oak:::index_for_recode(x = 1:5, from = c(2, 4)) #> [1] NA 1 NA 2 NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":null,"dir":"Reference","previous_headings":"","what":"Format as a ISO8601 month — iso8601_mon","title":"Format as a ISO8601 month — iso8601_mon","text":"iso8601_mon() converts character vector whose values represent numeric abbreviated month names zero-padded numeric months.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format as a ISO8601 month — iso8601_mon","text":"","code":"iso8601_mon(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format as a ISO8601 month — iso8601_mon","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format as a ISO8601 month — iso8601_mon","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format as a ISO8601 month — iso8601_mon","text":"","code":"sdtm.oak:::iso8601_mon(c(NA, \"0\", \"1\", \"2\", \"10\", \"11\", \"12\")) #> [1] NA \"00\" \"01\" \"02\" \"10\" \"11\" \"12\" # No semantic validation is performed on the numeric months, so `\"13\"` stays # `\"13\"` but representations that can't be represented as two-digit numbers # become `NA`. sdtm.oak:::iso8601_mon(c(\"13\", \"99\", \"100\", \"-1\")) #> [1] \"13\" \"99\" NA NA (mon <- month.abb) #> [1] \"Jan\" \"Feb\" \"Mar\" \"Apr\" \"May\" \"Jun\" \"Jul\" \"Aug\" \"Sep\" \"Oct\" \"Nov\" \"Dec\" sdtm.oak:::iso8601_mon(mon) #> [1] \"01\" \"02\" \"03\" \"04\" \"05\" \"06\" \"07\" \"08\" \"09\" \"10\" \"11\" \"12\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert NA to ","title":"Convert NA to ","text":"iso8601_na() takes character vector converts NA values \"-\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert NA to ","text":"","code":"iso8601_na(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert NA to ","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert NA to ","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert NA to ","text":"","code":"sdtm.oak:::iso8601_na(c(\"10\", NA_character_)) #> [1] \"10\" \"-\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":null,"dir":"Reference","previous_headings":"","what":"Format as ISO8601 seconds — iso8601_sec","title":"Format as ISO8601 seconds — iso8601_sec","text":"iso8601_sec() converts character vector whose values represent seconds.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format as ISO8601 seconds — iso8601_sec","text":"","code":"iso8601_sec(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format as ISO8601 seconds — iso8601_sec","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format as ISO8601 seconds — iso8601_sec","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format as ISO8601 seconds — iso8601_sec","text":"","code":"sdtm.oak:::iso8601_sec(c(NA, \"0\", \"1\", \"10\", \"59\", \"99\", \"100\")) #> [1] NA \"00\" \"01\" \"10\" \"59\" \"99\" NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":null,"dir":"Reference","previous_headings":"","what":"Truncate a partial ISO8601 date-time — iso8601_truncate","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"iso8601_truncate() converts character vector ISO8601 dates, times date-times might partial truncates format removing missing components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"","code":"iso8601_truncate(x, empty_as_na = TRUE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"","code":"x <- c( \"1999-01-01T15:20:01\", \"1999-01-01T15:20:-\", \"1999-01-01T15:-:-\", \"1999-01-01T-:-:-\", \"1999-01--T-:-:-\", \"1999----T-:-:-\", \"-----T-:-:-\" ) sdtm.oak:::iso8601_truncate(x) #> [1] \"1999-01-01T15:20:01\" \"1999-01-01T15:20\" \"1999-01-01T15\" #> [4] \"1999-01-01\" \"1999-01\" \"1999\" #> [7] NA # With `empty_as_na = FALSE` empty strings are not replaced with `NA` sdtm.oak:::iso8601_truncate(\"-----T-:-:-\", empty_as_na = TRUE) #> [1] NA sdtm.oak:::iso8601_truncate(\"-----T-:-:-\", empty_as_na = FALSE) #> [1] \"\" # Truncation only happens if missing components are the right most end, # otherwise they remain unaltered. sdtm.oak:::iso8601_truncate( c( \"1999----T15:20:01\", \"1999-01-01T-:20:01\", \"1999-01-01T-:-:01\", \"1999-01-01T-:-:-\" ) ) #> [1] \"1999----T15:20:01\" \"1999-01-01T-:20:01\" \"1999-01-01T-:-:01\" #> [4] \"1999-01-01\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":null,"dir":"Reference","previous_headings":"","what":"Format as a ISO8601 two-digit number — iso8601_two_digits","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"iso8601_two_digits() converts single digit two digit number two digit, 0-padded, number. Failing parse input two digit number results NA.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"","code":"iso8601_two_digits(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"character vector size x.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"","code":"x <- c(\"0\", \"00\", \"1\", \"01\", \"42\", \"100\", NA_character_, \"1.\") sdtm.oak:::iso8601_two_digits(x) #> [1] \"00\" \"00\" \"01\" \"01\" \"42\" NA NA NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":null,"dir":"Reference","previous_headings":"","what":"Format as a ISO8601 four-digit year — iso8601_year","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"iso8601_year() converts character vector whose values represent years four-digit years.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"","code":"iso8601_year(x, cutoff_2000 = 68L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"x character vector. cutoff_2000 non-negative integer value. Two-digit years smaller equal cutoff_2000 parsed though starting 20, otherwise parsed though starting 19.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"","code":"sdtm.oak:::iso8601_year(c(\"0\", \"1\", \"2\", \"50\", \"68\", \"69\", \"90\", \"99\", \"00\")) #> [1] \"2000\" \"2001\" \"2002\" \"2050\" \"2068\" \"1969\" \"1990\" \"1999\" \"2000\" # Be default, `cutoff_2000` is at 68. sdtm.oak:::iso8601_year(c(\"67\", \"68\", \"69\", \"70\")) #> [1] \"2067\" \"2068\" \"1969\" \"1970\" sdtm.oak:::iso8601_year(c(\"1967\", \"1968\", \"1969\", \"1970\")) #> [1] \"1967\" \"1968\" \"1969\" \"1970\" # Change it to something else, e.g. `cutoff_2000 = 25`. sdtm.oak:::iso8601_year(as.character(0:50), cutoff_2000 = 25) #> [1] \"2000\" \"2001\" \"2002\" \"2003\" \"2004\" \"2005\" \"2006\" \"2007\" \"2008\" \"2009\" #> [11] \"2010\" \"2011\" \"2012\" \"2013\" \"2014\" \"2015\" \"2016\" \"2017\" \"2018\" \"2019\" #> [21] \"2020\" \"2021\" \"2022\" \"2023\" \"2024\" \"2025\" \"1926\" \"1927\" \"1928\" \"1929\" #> [31] \"1930\" \"1931\" \"1932\" \"1933\" \"1934\" \"1935\" \"1936\" \"1937\" \"1938\" \"1939\" #> [41] \"1940\" \"1941\" \"1942\" \"1943\" \"1944\" \"1945\" \"1946\" \"1947\" \"1948\" \"1949\" #> [51] \"1950\" sdtm.oak:::iso8601_year(as.character(1900:1950), cutoff_2000 = 25) #> [1] \"1900\" \"1901\" \"1902\" \"1903\" \"1904\" \"1905\" \"1906\" \"1907\" \"1908\" \"1909\" #> [11] \"1910\" \"1911\" \"1912\" \"1913\" \"1914\" \"1915\" \"1916\" \"1917\" \"1918\" \"1919\" #> [21] \"1920\" \"1921\" \"1922\" \"1923\" \"1924\" \"1925\" \"1926\" \"1927\" \"1928\" \"1929\" #> [31] \"1930\" \"1931\" \"1932\" \"1933\" \"1934\" \"1935\" \"1936\" \"1937\" \"1938\" \"1939\" #> [41] \"1940\" \"1941\" \"1942\" \"1943\" \"1944\" \"1945\" \"1946\" \"1947\" \"1948\" \"1949\" #> [51] \"1950\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/months_abb_regex.html","id":null,"dir":"Reference","previous_headings":"","what":"Regex for months' abbreviations — months_abb_regex","title":"Regex for months' abbreviations — months_abb_regex","text":"months_abb_regex() generates regex matches month abbreviations. finer control, case can specified parameter case.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/months_abb_regex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regex for months' abbreviations — months_abb_regex","text":"","code":"months_abb_regex(x = month.abb, case = c(\"any\", \"upper\", \"lower\", \"title\"))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/months_abb_regex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regex for months' abbreviations — months_abb_regex","text":"x character vector three-letter month abbreviations. Default month.abb. case string scalar: \"\", month abbreviations matched case; \"upper\", match uppercase abbreviations; \"lower\", match lowercase; , \"title\" match title case.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/months_abb_regex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regex for months' abbreviations — months_abb_regex","text":"regex string.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Raw dataset keys — oak_id_vars","title":"Raw dataset keys — oak_id_vars","text":"oak_id_vars() helper function providing variable (column) names regarded keys tibbles representing raw datasets. default, set names oak_id, raw_source, patient_number. Extra variable names may indicated passed extra_vars appended default names.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Raw dataset keys — oak_id_vars","text":"","code":"oak_id_vars(extra_vars = NULL)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Raw dataset keys — oak_id_vars","text":"extra_vars character vector extra column names appended default names: oak_id, raw_source, patient_number.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Raw dataset keys — oak_id_vars","text":"character vector column names regarded keys raw datasets.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Raw dataset keys — oak_id_vars","text":"","code":"sdtm.oak:::oak_id_vars() #> [1] \"oak_id\" \"raw_source\" \"patient_number\" sdtm.oak:::oak_id_vars(extra_vars = \"sample_id\") #> [1] \"oak_id\" \"raw_source\" \"patient_number\" \"sample_id\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse a date, time, or date-time — parse_dttm_","title":"Parse a date, time, or date-time — parse_dttm_","text":"parse_dttm() extracts date time components. parse_dttm() wraps around parse_dttm_(), vectorized fmt.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse a date, time, or date-time — parse_dttm_","text":"","code":"parse_dttm_( dttm, fmt, fmt_c = fmt_cmp(), na = NULL, sec_na = na, min_na = na, hour_na = na, mday_na = na, mon_na = na, year_na = na ) parse_dttm( dttm, fmt, fmt_c = fmt_cmp(), na = NULL, sec_na = na, min_na = na, hour_na = na, mday_na = na, mon_na = na, year_na = na )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse a date, time, or date-time — parse_dttm_","text":"dttm character vector dates, times date-times. fmt case parse_dttm(), character vector parsing formats, single string format case parse_dttm_(). character vector formats passed, format attempted turn first parsing result successful taking precedence final result. formats fmt can strings, however following characters (successive repetitions thereof) reserved sense treated special way: \"y\": parsed year; \"m\": parsed month; \"d\": parsed day; \"H\": parsed hour; \"M\": parsed minute; \"S\": parsed second. na, sec_na, min_na, hour_na, mday_na, mon_na, year_na character vector alternative values allow matching. can used indicate different forms missing values found parsing date-time strings.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse a date, time, or date-time — parse_dttm_","text":"character matrix six columns: \"year\", \"mon\", \"mday\", \"hour\", \"min\" \"sec\". row corresponds element dttm. element matrix parsed date/time component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Parse a date, time, or date-time — parse_dttm_","text":"","code":"sdtm.oak:::parse_dttm(\"2020\", \"y\") #> year mon mday hour min sec #> [1,] \"2020\" NA NA NA NA NA sdtm.oak:::parse_dttm(\"2020-05\", \"y\") #> year mon mday hour min sec #> [1,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(\"2020-05\", \"y-m\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" NA NA NA NA sdtm.oak:::parse_dttm(\"2020-05-11\", \"y-m-d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" NA NA NA sdtm.oak:::parse_dttm(\"2020 05 11\", \"y m d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" NA NA NA sdtm.oak:::parse_dttm(\"2020 05 11\", \"y m d\") #> year mon mday hour min sec #> [1,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(\"2020 05 11\", \"y\\\\s+m\\\\s+d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" NA NA NA sdtm.oak:::parse_dttm(\"2020 05 11\", \"y\\\\s+m\\\\s+d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" NA NA NA sdtm.oak:::parse_dttm(\"2020-05-11 11:45\", \"y-m-d H:M\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" \"11\" \"45\" NA sdtm.oak:::parse_dttm(\"2020-05-11 11:45:15.6\", \"y-m-d H:M:S\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" \"11\" \"45\" \"15.6\" sdtm.oak:::parse_dttm(c(\"2002-05-11 11:45\", \"-05-11 11:45\"), \"y-m-d H:M\") #> year mon mday hour min sec #> [1,] \"2002\" \"05\" \"11\" \"11\" \"45\" NA #> [2,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(c(\"2002-05-11 11:45\", \"-05-11 11:45\"), \"-m-d H:M\") #> year mon mday hour min sec #> [1,] NA NA NA NA NA NA #> [2,] NA \"05\" \"11\" \"11\" \"45\" NA sdtm.oak:::parse_dttm(c(\"2002-05-11 11:45\", \"-05-11 11:45\"), c(\"y-m-d H:M\", \"-m-d H:M\")) #> year mon mday hour min sec #> [1,] \"2002\" \"05\" \"11\" \"11\" \"45\" NA #> [2,] NA \"05\" \"11\" \"11\" \"45\" NA sdtm.oak:::parse_dttm(\"05 feb 1985 12 55 02\", \"d m y H M S\") #> year mon mday hour min sec #> [1,] \"1985\" \"feb\" \"05\" \"12\" \"55\" \"02\" sdtm.oak:::parse_dttm(\"12 55 02 05 feb 1985\", \"H M S d m y\") #> year mon mday hour min sec #> [1,] \"1985\" \"feb\" \"05\" \"12\" \"55\" \"02\" sdtm.oak:::parse_dttm(c(\"2020-05-18\", \"2020-UN-18\", \"2020-UNK-UN\"), \"y-m-d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"18\" NA NA NA #> [2,] NA NA NA NA NA NA #> [3,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(c(\"2020-05-18\", \"2020-UN-18\", \"2020-UNK-UN\"), \"y-m-d\", na = \"UN\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"18\" NA NA NA #> [2,] \"2020\" \"UN\" \"18\" NA NA NA #> [3,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(c(\"2020-05-18\", \"2020-UN-18\", \"2020-UNK-UN\"), \"y-m-d\", na = c(\"UN\", \"UNK\")) #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"18\" NA NA NA #> [2,] \"2020\" \"UN\" \"18\" NA NA NA #> [3,] \"2020\" \"UNK\" \"UN\" NA NA NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse a date/time format — parse_dttm_fmt_","title":"Parse a date/time format — parse_dttm_fmt_","text":"parse_dttm_fmt() parses date/time formats, meaning try parse components format fmt refer date/time components. parse_dttm_fmt_() similar parse_dttm_fmt() vectorized fmt.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse a date/time format — parse_dttm_fmt_","text":"","code":"parse_dttm_fmt_(fmt, pattern) parse_dttm_fmt(fmt, patterns = fmt_cmp())"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse a date/time format — parse_dttm_fmt_","text":"fmt format string (scalar) parsed patterns. pattern, patterns string (case pattern), character vector (case patterns) regexps individual date/time components. Default value fmt_cmp(). Use function plan passing different set patterns.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse a date/time format — parse_dttm_fmt_","text":"tibble seven columns: fmt_c: date/time format component. Values either \"year\", \"mon\", \"mday\", \"hour\", \"min\", \"sec\", NA. pat: Regexp used parse date/time component. cap: captured substring format. start: Start position format string capture. end: End position format string capture. len: Length capture (number chars). ord: Ordinal date/time component format string. row either date/time format component \"delimiter\" string pattern -format components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Parse a date/time format — parse_dttm_fmt_","text":"","code":"sdtm.oak:::parse_dttm_fmt(\"ymd\") #> # A tibble: 3 × 7 #> fmt_c pat cap start end len ord #> #> 1 year y+ y 1 1 1 1 #> 2 mon m+ m 2 2 1 2 #> 3 mday d+ d 3 3 1 3 sdtm.oak:::parse_dttm_fmt(\"H:M:S\") #> # A tibble: 5 × 7 #> fmt_c pat cap start end len ord #> #> 1 hour H+ H 1 1 1 1 #> 2 NA NA : 2 2 1 NA #> 3 min M+ M 3 3 1 2 #> 4 NA NA : 4 4 1 NA #> 5 sec S+ S 5 5 1 3 sdtm.oak:::parse_dttm_fmt(\"ymd HMS\") #> # A tibble: 7 × 7 #> fmt_c pat cap start end len ord #> #> 1 year y+ \"y\" 1 1 1 1 #> 2 mon m+ \"m\" 2 2 1 2 #> 3 mday d+ \"d\" 3 3 1 3 #> 4 NA NA \" \" 4 4 1 NA #> 5 hour H+ \"H\" 5 5 1 4 #> 6 min M+ \"M\" 6 6 1 5 #> 7 sec S+ \"S\" 7 7 1 6 # Repeating the same special patterns, e.g. \"yy\" still counts as one pattern # only. sdtm.oak:::parse_dttm_fmt(\"yymmdd HHMMSS\") #> # A tibble: 7 × 7 #> fmt_c pat cap start end len ord #> #> 1 year y+ \"yy\" 1 2 2 1 #> 2 mon m+ \"mm\" 3 4 2 2 #> 3 mday d+ \"dd\" 5 6 2 3 #> 4 NA NA \" \" 7 7 1 NA #> 5 hour H+ \"HH\" 8 9 2 4 #> 6 min M+ \"MM\" 10 11 2 5 #> 7 sec S+ \"SS\" 12 13 2 6 # Note that `\"y\"`, `\"m\"`, `\"d\"`, `\"H\"`, `\"M\"` or `\"S\"` are reserved patterns # that are matched first and interpreted as format components. # Example: the # first \"y\" in \"year\" is parsed as meaning year followed by \"ear y\". The # second \"y\" is not longer matched because a first match already # succeded. sdtm.oak:::parse_dttm_fmt(\"year y\") #> # A tibble: 2 × 7 #> fmt_c pat cap start end len ord #> #> 1 year y+ y 1 1 1 1 #> 2 NA NA ear y 2 6 5 NA # Specify custom patterns sdtm.oak:::parse_dttm_fmt( \"year month day\", fmt_cmp(year = \"year\", mon = \"month\", mday = \"day\") ) #> # A tibble: 5 × 7 #> fmt_c pat cap start end len ord #> #> 1 year year \"year\" 1 4 4 1 #> 2 NA NA \" \" 5 5 1 NA #> 3 mon month \"month\" 6 10 5 2 #> 4 NA NA \" \" 11 11 1 NA #> 5 mday day \"day\" 12 14 3 3"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve date/time parsing problems — problems","title":"Retrieve date/time parsing problems — problems","text":"problems() companion helper function create_iso8601(). retrieves ISO 8601 parsing problems object class iso8601, create_iso8601()'s return value might contain problems attribute case parsing failures. problems() helper function provides easy access parsing problems.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve date/time parsing problems — problems","text":"","code":"problems(x = .Last.value)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve date/time parsing problems — problems","text":"x object class iso8601, typically obtained call create_iso8601(). argument can also left empty, case problems() use last returned value, making convenient use immediately create_iso8601().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve date/time parsing problems — problems","text":"parsing problems x, returned value NULL; otherwise, tibble parsing failures returned. row corresponds parsing problem. first column named ..indicating position(s) inputs create_iso8601() call resulted failures; remaining columns correspond original input values passed create_iso8601(), columns automatically named ..var1, ..var2, , inputs create_iso8601() unnamed, otherwise, original variable names used instead.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve date/time parsing problems — problems","text":"","code":"dates <- c( \"2020-01-01\", \"2020-02-11\", \"2020-01-06\", \"2020-0921\", \"2020/10/30\", \"2020-12-05\", \"20231225\" ) # By inspecting the problematic dates it can be understood that # the `.format` parameter needs to updated to include other variations. iso8601_dttm <- create_iso8601(dates, .format = \"y-m-d\") problems(iso8601_dttm) #> # A tibble: 3 × 2 #> ..i ..var1 #> #> 1 4 2020-0921 #> 2 5 2020/10/30 #> 3 7 20231225 # Including more parsing formats addresses the previous problems formats <- c(\"y-m-d\", \"y-md\", \"y/m/d\", \"ymd\") iso8601_dttm2 <- create_iso8601(dates, .format = list(formats)) # So now `problems()` returns `NULL` because there are no more parsing issues. problems(iso8601_dttm2) # If you pass named arguments when calling `create_iso8601()` then they will # be used to create the problems object. iso8601_dttm3 <- create_iso8601(date = dates, .format = \"y-m-d\") problems(iso8601_dttm3) #> # A tibble: 3 × 2 #> ..i date #> #> 1 4 2020-0921 #> 2 5 2020/10/30 #> 3 7 20231225"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/pseq.html","id":null,"dir":"Reference","previous_headings":"","what":"Parallel sequence generation — pseq","title":"Parallel sequence generation — pseq","text":"pseq() similar seq() conveniently accepts integer vectors inputs , allowing parallel generation sequences. result union generated sequences.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/pseq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parallel sequence generation — pseq","text":"","code":"pseq(from, to)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/pseq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parallel sequence generation — pseq","text":"integer vector. starting value(s) sequence(s). integer vector. ending value(s) sequence(s).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/pseq.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parallel sequence generation — pseq","text":"integer vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":null,"dir":"Reference","previous_headings":"","what":"Read in a controlled terminology — read_ct_spec","title":"Read in a controlled terminology — read_ct_spec","text":"read_ct_spec() imports controlled terminology specification data set tibble.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read in a controlled terminology — read_ct_spec","text":"","code":"read_ct_spec(file = stop(\"`file` must be specified\"))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read in a controlled terminology — read_ct_spec","text":"file path file containing controlled terminology specification data set. following expected file: file expected CSV file; file expected contain first row column names; minimal set variables expected: codelist_code, collected_value, term_synonyms, term_value.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read in a controlled terminology — read_ct_spec","text":"tibble controlled terminology specification.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read in a controlled terminology — read_ct_spec","text":"","code":"# Get the local path to one of the controlled terminology example files. path <- ct_spec_example(\"ct-01-cm\") # Import it to R. read_ct_spec(file = path) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist "},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":null,"dir":"Reference","previous_headings":"","what":"Read an example controlled terminology specification — read_ct_spec_example","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"read_ct_spec_example() imports one bundled controlled terminology specification data sets tibble R.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"","code":"read_ct_spec_example(example)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"example file name controlled terminology data set bundled {stdm.oak}, run read_ct_spec_example() available example files.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"tibble controlled terminology specification data set, character vector example file names.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"","code":"# Leave the `example` parameter as missing for available example files. read_ct_spec_example() #> [1] \"ct-01-cm.csv\" # Read an example controlled terminology spec file. read_ct_spec_example(\"ct-01-cm.csv\") #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # You may omit the file extension. read_ct_spec_example(\"ct-01-cm\") #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist "},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":null,"dir":"Reference","previous_headings":"","what":"Recode values — recode","title":"Recode values — recode","text":"recode() recodes values x matching elements onto values .","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Recode values — recode","text":"","code":"recode(x, from = unique(na.omit(x)), to = from, .no_match = x, .na = NA)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Recode values — recode","text":"x atomic vector values recoded. vector values matched x recoding. vector values used replacement values . .no_match Value used replacement cases matched. .na Value used recode missing values.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Recode values — recode","text":"vector recoded values.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Recode values — recode","text":"","code":"x <- c(\"male\", \"female\", \"x\", NA) sdtm.oak:::recode(x, from = c(\"male\", \"female\"), to = c(\"M\", \"F\") ) #> [1] \"M\" \"F\" \"x\" NA sdtm.oak:::recode( x, from = c(\"male\", \"female\"), to = c(\"M\", \"F\"), .no_match = \"?\" ) #> [1] \"M\" \"F\" \"?\" NA sdtm.oak:::recode( x, from = c(\"male\", \"female\"), to = c(\"M\", \"F\"), .na = \"missing\" ) #> [1] \"M\" \"F\" \"x\" \"missing\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/reg_matches.html","id":null,"dir":"Reference","previous_headings":"","what":"regmatches() with NA — reg_matches","title":"regmatches() with NA — reg_matches","text":"reg_matches() thin wrapper around regmatches() returns NA instead character(0) matching fails.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/reg_matches.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"regmatches() with NA — reg_matches","text":"","code":"reg_matches(x, m, invert = FALSE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/reg_matches.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"regmatches() with NA — reg_matches","text":"x character vector. m object match data. invert logical scalar. TRUE, extract replace non-matched substrings.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/reg_matches.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"regmatches() with NA — reg_matches","text":"list character vectors matched substrings, NA matching failed.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":null,"dir":"Reference","previous_headings":"","what":"Utility function to assemble a regex of alternative patterns — regex_or","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"regex_or() takes set patterns binds (\"|\") pattern easy regex alternative patterns.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"","code":"regex_or(x, .open = FALSE, .close = FALSE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"x character vector alternative patterns. .open Whether resulting regex start \"|\". .close Whether resulting regex end \"|\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"character scalar resulting regex.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"","code":"# A regex for matching either \"jan\" or \"feb\" sdtm.oak:::regex_or(c(\"jan\", \"feb\")) #> [1] \"jan|feb\" # Setting `.open` and/or `.close` to `TRUE` can be handy if this regex # is to be combined into a larger regex. paste0(sdtm.oak:::regex_or(c(\"jan\", \"feb\"), .close = TRUE), r\"{\\d{2}}\") #> [1] \"jan|feb|\\\\d{2}\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm.oak-package.html","id":null,"dir":"Reference","previous_headings":"","what":"sdtm.oak: SDTM Data Transformation Engine — sdtm.oak-package","title":"sdtm.oak: SDTM Data Transformation Engine — sdtm.oak-package","text":"EDC Data Standard-agnostic SDTM data transformation engine designed SDTM programming R. Powered metadata sdtm.oak can automate conversion raw clinical data SDTM standardized mapping algorithms. SDTM one required standards data submission FDA (U.S.) PMDA (Japan). SDTM standards implemented accordance SDTM Implementation Guide defined CDISC https://www.cdisc.org/standards/foundational/sdtmig.","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm.oak-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"sdtm.oak: SDTM Data Transformation Engine — sdtm.oak-package","text":"Maintainer: Rammprasad Ganapathy ganapathy.rammprasad@gene.com Authors: Adam Forys Edgar Manukyan Rosemary Li Preetesh Parikh Lisa Houterloot Yogesh Gupta Omar Garcia ogcalderon@cdisc.org Ramiro Magno rmagno@pattern.institute (ORCID) contributors: Pattern Institute [copyright holder, funder] F. Hoffmann-La Roche AG [copyright holder, funder] Pfizer Inc [copyright holder, funder]","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_assign.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an SDTM variable — sdtm_assign","title":"Derive an SDTM variable — sdtm_assign","text":"sdtm_assign() internal function packing functionality assign_no_ct() assign_ct() together aimed developers . user please use either assign_no_ct() assign_ct().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_assign.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an SDTM variable — sdtm_assign","text":"","code":"sdtm_assign( raw_dat, raw_var, tgt_var, ct_spec = NULL, ct_clst = NULL, tgt_dat = NULL, id_vars = oak_id_vars() )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_assign.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an SDTM variable — sdtm_assign","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable: single string indicating name raw variable raw_dat. tgt_var target SDTM variable: single string indicating name variable derived. ct_spec Study controlled terminology specification: dataframe minimal set columns, see ct_spec_vars() details. parameter optional, left NULL controlled terminology recoding applied. ct_clst codelist code indicating subset controlled terminology apply derivation. parameter optional, left NULL, possible recodings ct_spec attempted. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (raw_dat).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_assign.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an SDTM variable — sdtm_assign","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_hardcode.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","title":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","text":"sdtm_hardcode() internal function packing functionality hardcode_no_ct() hardcode_ct() together aimed developers . user please use either hardcode_no_ct() hardcode_ct().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_hardcode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","text":"","code":"sdtm_hardcode( raw_dat, raw_var, tgt_var, tgt_val, ct_spec = NULL, ct_clst = NULL, tgt_dat = NULL, id_vars = oak_id_vars() )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_hardcode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable: single string indicating name raw variable raw_dat. tgt_var target SDTM variable: single string indicating name variable derived. tgt_val target SDTM value hardcoded variable indicated tgt_var. ct_spec Study controlled terminology specification: dataframe minimal set columns, see ct_spec_vars() details. parameter optional, left NULL controlled terminology recoding applied. ct_clst codelist code indicating subset controlled terminology apply derivation. parameter optional, left NULL, possible recodings ct_spec attempted. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (raw_dat).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_hardcode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/str_to_anycase.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate case insensitive regexps — str_to_anycase","title":"Generate case insensitive regexps — str_to_anycase","text":"str_to_anycase() takes character vector word strings input, generates regular expressions express match case.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/str_to_anycase.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate case insensitive regexps — str_to_anycase","text":"","code":"str_to_anycase(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/str_to_anycase.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate case insensitive regexps — str_to_anycase","text":"x character vector strings consisting word characters.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/str_to_anycase.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate case insensitive regexps — str_to_anycase","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert two-digit to four-digit years — yy_to_yyyy","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"yy_to_yyyy() converts two-digit years four-digit years.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"","code":"yy_to_yyyy(x, cutoff_2000 = 68L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"x integer vector years. cutoff_2000 integer value. Two-digit years smaller equal cutoff_2000 parsed though starting 20, otherwise parsed though starting 19.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"integer vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"","code":"sdtm.oak:::yy_to_yyyy(0:5) #> [1] 2000 2001 2002 2003 2004 2005 sdtm.oak:::yy_to_yyyy(2000:2005) #> [1] 2000 2001 2002 2003 2004 2005 sdtm.oak:::yy_to_yyyy(90:99) #> [1] 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 sdtm.oak:::yy_to_yyyy(1990:1999) #> [1] 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 # NB: change in behavior after 68 sdtm.oak:::yy_to_yyyy(65:72) #> [1] 2065 2066 2067 2068 1969 1970 1971 1972 sdtm.oak:::yy_to_yyyy(1965:1972) #> [1] 1965 1966 1967 1968 1969 1970 1971 1972"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"zero_pad_whole_number() takes non-negative integer values converts character zero padding. Negative numbers numbers greater width specified number digits n converted NA.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"","code":"zero_pad_whole_number(x, n = 2L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"x integer vector. n Number digits output, including zero padding.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"","code":"sdtm.oak:::zero_pad_whole_number(c(-1, 0, 1)) #> [1] NA \"00\" \"01\" sdtm.oak:::zero_pad_whole_number(c(-1, 0, 1, 10, 99, 100), n = 2) #> [1] NA \"00\" \"01\" \"10\" \"99\" NA sdtm.oak:::zero_pad_whole_number(c(-1, 0, 1, 10, 99, 100), n = 3) #> [1] NA \"000\" \"001\" \"010\" \"099\" \"100\""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/news/index.html","id":"new-features-0-0-0-9003","dir":"Changelog","previous_headings":"","what":"New Features","title":"sdtm.oak 0.0.0.9003 (development version)","text":"New function: assign_datetime() deriving ISO8601 date-time variable.","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/news/index.html","id":"new-features-0-0-0-9002","dir":"Changelog","previous_headings":"","what":"New Features","title":"sdtm.oak 0.0.0.9002 (development version)","text":"New function: derive_study_day() study day calculation. New functions basic SDTM derivations: assign_no_ct(), assign_ct(), hardcode_no_ct() hardcode_ct(). New functions handling controlled terminologies: read_ct_spec(), read_ct_spec_example(), ct_spec_example() ct_map().","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/news/index.html","id":"new-features-0-0-0-9001","dir":"Changelog","previous_headings":"","what":"New Features","title":"sdtm.oak 0.0.0.9001 (development version)","text":"New function create_iso8601() conversion vectors dates, times date-times ISO8601 format.","code":""}] +[{"path":"https://pharmaverse.github.io/sdtm.oak/CODE_OF_CONDUCT.html","id":null,"dir":"","previous_headings":"","what":"Contributor Code of Conduct","title":"Contributor Code of Conduct","text":"contributors maintainers project, pledge respect people contribute reporting issues, posting feature requests, updating documentation, submitting pull requests patches, activities. committed making participation project harassment-free experience everyone, regardless level experience, gender, gender identity expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion. Examples unacceptable behavior participants include use sexual language imagery, derogatory comments personal attacks, trolling, public private harassment, insults, unprofessional conduct. Project maintainers right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct. Project maintainers follow Code Conduct may removed project team. Instances abusive, harassing, otherwise unacceptable behavior may reported opening issue contacting one project maintainers. Code Conduct adapted Contributor Covenant (http://contributor-covenant.org), version 1.0.0, available http://contributor-covenant.org/version/1/0/0/","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contribution to {sdtm.oak}","title":"Contribution to {sdtm.oak}","text":"outlines propose change sdtm.oak package. detailed info contributing {sdtm.oak}, pharmaverse packages, please see Contribution Guide well Developer Guides Articles section {admiraldev} website. Please note try align best practices used R packages’ development processes - veteran developers familiar processes. However, deviate slightly best practices advise new contributors review package documentation accordingly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/CONTRIBUTING.html","id":"basics","dir":"","previous_headings":"","what":"Basics","title":"Contribution to {sdtm.oak}","text":"new contribution, user creates issue issue tab GitHub put backlog. issues can range bug identification /fixes, enhancements functions, documentation, tests new features. advise contact us issue created via Slack (don’t access, use link join). can discuss details align expectations familiar sdtm.oak philosophy programming strategy. team try review issues within next backlog meeting give initial feedback. Since 100% fully resourced software development team might issues take longer respond depending amount overall issues.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"Apache License","title":"Apache License","text":"Version 2.0, January 2004 ","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_1-definitions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"1. Definitions","title":"Apache License","text":"“License” shall mean terms conditions use, reproduction, distribution defined Sections 1 9 document. “Licensor” shall mean copyright owner entity authorized copyright owner granting License. “Legal Entity” shall mean union acting entity entities control, controlled , common control entity. purposes definition, “control” means () power, direct indirect, cause direction management entity, whether contract otherwise, (ii) ownership fifty percent (50%) outstanding shares, (iii) beneficial ownership entity. “” (“”) shall mean individual Legal Entity exercising permissions granted License. “Source” form shall mean preferred form making modifications, including limited software source code, documentation source, configuration files. “Object” form shall mean form resulting mechanical transformation translation Source form, including limited compiled object code, generated documentation, conversions media types. “Work” shall mean work authorship, whether Source Object form, made available License, indicated copyright notice included attached work (example provided Appendix ). “Derivative Works” shall mean work, whether Source Object form, based (derived ) Work editorial revisions, annotations, elaborations, modifications represent, whole, original work authorship. purposes License, Derivative Works shall include works remain separable , merely link (bind name) interfaces , Work Derivative Works thereof. “Contribution” shall mean work authorship, including original version Work modifications additions Work Derivative Works thereof, intentionally submitted Licensor inclusion Work copyright owner individual Legal Entity authorized submit behalf copyright owner. purposes definition, “submitted” means form electronic, verbal, written communication sent Licensor representatives, including limited communication electronic mailing lists, source code control systems, issue tracking systems managed , behalf , Licensor purpose discussing improving Work, excluding communication conspicuously marked otherwise designated writing copyright owner “Contribution.” “Contributor” shall mean Licensor individual Legal Entity behalf Contribution received Licensor subsequently incorporated within Work.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_2-grant-of-copyright-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"2. Grant of Copyright License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable copyright license reproduce, prepare Derivative Works , publicly display, publicly perform, sublicense, distribute Work Derivative Works Source Object form.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_3-grant-of-patent-license","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"3. Grant of Patent License","title":"Apache License","text":"Subject terms conditions License, Contributor hereby grants perpetual, worldwide, non-exclusive, -charge, royalty-free, irrevocable (except stated section) patent license make, made, use, offer sell, sell, import, otherwise transfer Work, license applies patent claims licensable Contributor necessarily infringed Contribution(s) alone combination Contribution(s) Work Contribution(s) submitted. institute patent litigation entity (including cross-claim counterclaim lawsuit) alleging Work Contribution incorporated within Work constitutes direct contributory patent infringement, patent licenses granted License Work shall terminate date litigation filed.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_4-redistribution","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"4. Redistribution","title":"Apache License","text":"may reproduce distribute copies Work Derivative Works thereof medium, without modifications, Source Object form, provided meet following conditions: () must give recipients Work Derivative Works copy License; (b) must cause modified files carry prominent notices stating changed files; (c) must retain, Source form Derivative Works distribute, copyright, patent, trademark, attribution notices Source form Work, excluding notices pertain part Derivative Works; (d) Work includes “NOTICE” text file part distribution, Derivative Works distribute must include readable copy attribution notices contained within NOTICE file, excluding notices pertain part Derivative Works, least one following places: within NOTICE text file distributed part Derivative Works; within Source form documentation, provided along Derivative Works; , within display generated Derivative Works, wherever third-party notices normally appear. contents NOTICE file informational purposes modify License. may add attribution notices within Derivative Works distribute, alongside addendum NOTICE text Work, provided additional attribution notices construed modifying License. may add copyright statement modifications may provide additional different license terms conditions use, reproduction, distribution modifications, Derivative Works whole, provided use, reproduction, distribution Work otherwise complies conditions stated License.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_5-submission-of-contributions","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"5. Submission of Contributions","title":"Apache License","text":"Unless explicitly state otherwise, Contribution intentionally submitted inclusion Work Licensor shall terms conditions License, without additional terms conditions. Notwithstanding , nothing herein shall supersede modify terms separate license agreement may executed Licensor regarding Contributions.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_6-trademarks","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"6. Trademarks","title":"Apache License","text":"License grant permission use trade names, trademarks, service marks, product names Licensor, except required reasonable customary use describing origin Work reproducing content NOTICE file.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_7-disclaimer-of-warranty","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"7. Disclaimer of Warranty","title":"Apache License","text":"Unless required applicable law agreed writing, Licensor provides Work (Contributor provides Contributions) “” BASIS, WITHOUT WARRANTIES CONDITIONS KIND, either express implied, including, without limitation, warranties conditions TITLE, NON-INFRINGEMENT, MERCHANTABILITY, FITNESS PARTICULAR PURPOSE. solely responsible determining appropriateness using redistributing Work assume risks associated exercise permissions License.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_8-limitation-of-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"8. Limitation of Liability","title":"Apache License","text":"event legal theory, whether tort (including negligence), contract, otherwise, unless required applicable law (deliberate grossly negligent acts) agreed writing, shall Contributor liable damages, including direct, indirect, special, incidental, consequential damages character arising result License use inability use Work (including limited damages loss goodwill, work stoppage, computer failure malfunction, commercial damages losses), even Contributor advised possibility damages.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"id_9-accepting-warranty-or-additional-liability","dir":"","previous_headings":"Terms and Conditions for use, reproduction, and distribution","what":"9. Accepting Warranty or Additional Liability","title":"Apache License","text":"redistributing Work Derivative Works thereof, may choose offer, charge fee , acceptance support, warranty, indemnity, liability obligations /rights consistent License. However, accepting obligations, may act behalf sole responsibility, behalf Contributor, agree indemnify, defend, hold Contributor harmless liability incurred , claims asserted , Contributor reason accepting warranty additional liability. END TERMS CONDITIONS","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/LICENSE.html","id":"appendix-how-to-apply-the-apache-license-to-your-work","dir":"","previous_headings":"","what":"APPENDIX: How to apply the Apache License to your work","title":"Apache License","text":"apply Apache License work, attach following boilerplate notice, fields enclosed brackets [] replaced identifying information. (Don’t include brackets!) text enclosed appropriate comment syntax file format. also recommend file class name description purpose included “printed page” copyright notice easier identification within third-party archives.","code":"Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/algorithms.html","id":"core-concept","dir":"Articles","previous_headings":"","what":"Core Concept","title":"Algorithms & Sub-Algorithms","text":"SDTM mappings defined algorithms transform collected (eCRF, eDT) source data target SDTM data model. Mapping algorithms backbone sdtm.oak - SDTM data transformation engine. Key Points: Algorithms can re-used across multiple SDTM domains. Algorithms pre-specified data collection standards MDR (applicable) Programming language agnostic - concept rely specific programming language implementation. OAK team implemented R functions. example reusing algorithm across multiple domains, variables, also non-standard","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/algorithms.html","id":"sub-algorithms","dir":"Articles","previous_headings":"","what":"Sub-algorithms","title":"Algorithms & Sub-Algorithms","text":"sdtm.oak supports two levels defining algorithms. example, SDTM mappings certain action taken condition met. cases, primary algorithm checks condition, sub-algorithm executes mappings condition met. Currently, sub-algorithms must provided main algorithms. IF_THEN_ELSE DATASET_LEVEL Algorithms can interchangeably used algorithms sub-algorithms seen (exhaustive list) permutation & combination algorithms & sub-algorithms creates endless possibilities accommodate different types mappings.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Converting dates, times or date-times to ISO 8601","text":"perform conversion ISO 8601 format need pass two key arguments: least one vector dates, times, date-times character type; date/time format via .format parameter instructs create_iso8601() date/time components expect. default .format parameter understands reserved characters: \"y\" year \"m\" month \"d\" day \"H\" hours \"M\" minutes \"S\" seconds Besides character vectors dates times, may also pass single vector date-times, provided adjust format:","code":"create_iso8601(\"2000 01 05\", .format = \"y m d\") #> [1] \"2000-01-05\" create_iso8601(\"22:35:05\", .format = \"H:M:S\") #> [1] \"-----T22:35:05\" create_iso8601(\"2000-01-05 22:35:05\", .format = \"y-m-d H:M:S\") #> [1] \"2000-01-05T22:35:05\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"multiple-inputs","dir":"Articles","previous_headings":"","what":"Multiple inputs","title":"Converting dates, times or date-times to ISO 8601","text":"dates times separate vectors need pass format vector: addition, like R functions take vectors input, create_iso8601() vectorized: number elements inputs match get error: can combine individual date time components coming separate inputs; contrived example year, month day together, hour, minute: .format argument must always named; otherwise, treated one inputs interpreted missing.","code":"create_iso8601(\"2000-01-05\", \"22:35:05\", .format = c(\"y-m-d\", \"H:M:S\")) #> [1] \"2000-01-05T22:35:05\" date <- c(\"2000-01-05\", \"2001-12-25\", \"1980-06-18\", \"1979-09-07\") time <- c(\"00:12:21\", \"22:35:05\", \"03:00:15\", \"07:09:00\") create_iso8601(date, time, .format = c(\"y-m-d\", \"H:M:S\")) #> [1] \"2000-01-05T00:12:21\" \"2001-12-25T22:35:05\" \"1980-06-18T03:00:15\" #> [4] \"1979-09-07T07:09:00\" date <- c(\"2000-01-05\", \"2001-12-25\", \"1980-06-18\", \"1979-09-07\") time <- \"00:12:21\" try(create_iso8601(date, time, .format = c(\"y-m-d\", \"H:M:S\"))) #> Error in create_iso8601(date, time, .format = c(\"y-m-d\", \"H:M:S\")) : #> All vectors in `...` must be of the same length. year <- c(\"99\", \"84\", \"00\", \"80\", \"79\", \"1944\", \"1953\") month_and_day <- c(\"jan 1\", \"apr 04\", \"mar 06\", \"jun 18\", \"sep 07\", \"sep 13\", \"sep 14\") hour <- c(\"12\", \"13\", \"05\", \"23\", \"16\", \"16\", \"19\") min <- c(\"0\", \"60\", \"59\", \"42\", \"44\", \"10\", \"13\") create_iso8601(year, month_and_day, hour, min, .format = c(\"y\", \"m d\", \"H\", \"M\")) #> [1] \"1999-01-01T12:00\" \"1984-04-04T13:60\" \"2000-03-06T05:59\" \"1980-06-18T23:42\" #> [5] \"1979-09-07T16:44\" \"1944-09-13T16:10\" \"1953-09-14T19:13\" try(create_iso8601(\"2000-01-05\", \"y-m-d\")) #> Error in create_iso8601(\"2000-01-05\", \"y-m-d\") : #> argument \".format\" is missing, with no default"},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"format-variations","dir":"Articles","previous_headings":"","what":"Format variations","title":"Converting dates, times or date-times to ISO 8601","text":".format parameter can easily accommodate variations format inputs: Individual components may come different order, adjust format accordingly: individual characters given format taken strictly, e.g. number spaces matters: format can include regular expressions though: default, streak reserved characters treated one provided, formats equivalent:","code":"create_iso8601(\"2000-01-05\", .format = \"y-m-d\") #> [1] \"2000-01-05\" create_iso8601(\"2000 01 05\", .format = \"y m d\") #> [1] \"2000-01-05\" create_iso8601(\"2000/01/05\", .format = \"y/m/d\") #> [1] \"2000-01-05\" create_iso8601(\"2000 01 05\", .format = \"y m d\") #> [1] \"2000-01-05\" create_iso8601(\"05 01 2000\", .format = \"d m y\") #> [1] \"2000-01-05\" create_iso8601(\"01 05, 2000\", .format = \"m d, y\") #> [1] \"2000-01-05\" date <- c(\"2000 01 05\", \"2000 01 05\", \"2000 01 05\", \"2000 01 05\") create_iso8601(date, .format = \"y m d\") #> [1] \"2000-01-05\" NA NA NA create_iso8601(date, .format = \"y m d\") #> [1] NA \"2000-01-05\" NA NA create_iso8601(date, .format = \"y m d\") #> [1] NA NA \"2000-01-05\" NA create_iso8601(date, .format = \"y m d\") #> [1] NA NA NA \"2000-01-05\" create_iso8601(date, .format = \"y\\\\s+m\\\\s+d\") #> [1] \"2000-01-05\" \"2000-01-05\" \"2000-01-05\" \"2000-01-05\" date <- c(\"2000-01-05\", \"2001-12-25\", \"1980-06-18\", \"1979-09-07\") time <- c(\"00:12:21\", \"22:35:05\", \"03:00:15\", \"07:09:00\") create_iso8601(date, time, .format = c(\"y-m-d\", \"H:M:S\")) #> [1] \"2000-01-05T00:12:21\" \"2001-12-25T22:35:05\" \"1980-06-18T03:00:15\" #> [4] \"1979-09-07T07:09:00\" create_iso8601(date, time, .format = c(\"yyyy-mm-dd\", \"HH:MM:SS\")) #> [1] \"2000-01-05T00:12:21\" \"2001-12-25T22:35:05\" \"1980-06-18T03:00:15\" #> [4] \"1979-09-07T07:09:00\" create_iso8601(date, time, .format = c(\"yyyyyyyy-m-dddddd\", \"H:MMMMM:SSSS\")) #> [1] \"2000-01-05T00:12:21\" \"2001-12-25T22:35:05\" \"1980-06-18T03:00:15\" #> [4] \"1979-09-07T07:09:00\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"multiple-alternative-formats","dir":"Articles","previous_headings":"","what":"Multiple alternative formats","title":"Converting dates, times or date-times to ISO 8601","text":"input vector contains values varying formats, single format may adequate encompass variations. situations, ’s advisable list multiple alternative formats. approach ensures format tried sequentially one matches data vector. Consider order supply formats, can significant. multiple formats potentially match, sequence determines format applied first. Note passing alternative formats, .format argument must list whose length matches number inputs.","code":"date <- c(\"2000/01/01\", \"2000-01-02\", \"2000 01 03\", \"2000/01/04\") create_iso8601(date, .format = \"y-m-d\") #> [1] NA \"2000-01-02\" NA NA create_iso8601(date, .format = \"y m d\") #> [1] NA NA \"2000-01-03\" NA create_iso8601(date, .format = \"y/m/d\") #> [1] \"2000-01-01\" NA NA \"2000-01-04\" create_iso8601(date, .format = list(c(\"y-m-d\", \"y m d\", \"y/m/d\"))) #> [1] \"2000-01-01\" \"2000-01-02\" \"2000-01-03\" \"2000-01-04\" create_iso8601(\"07 04 2000\", .format = list(c(\"d m y\", \"m d y\"))) #> [1] \"2000-04-07\" create_iso8601(\"07 04 2000\", .format = list(c(\"m d y\", \"d m y\"))) #> [1] \"2000-07-04\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"parsing-of-date-or-time-components","dir":"Articles","previous_headings":"","what":"Parsing of date or time components","title":"Converting dates, times or date-times to ISO 8601","text":"default, date time components parsed follows: year: either parsed two- four-digit year; month: either numeric month (single two-digit number) English abbreviated month name (e.g. Jan, Jun Dec) regardless case; month day: parsed two-digit numbers; hour minute: parsed single two-digit numbers; second: parsed single two-digit numbers optional fractional part.","code":"# Years: two-digit or four-digit numbers. years <- c(\"0\", \"1\", \"00\", \"01\", \"15\", \"30\", \"50\", \"68\", \"69\", \"80\", \"99\") create_iso8601(years, .format = \"y\") #> [1] NA NA \"2000\" \"2001\" \"2015\" \"2030\" \"2050\" \"2068\" \"1969\" \"1980\" #> [11] \"1999\" # Adjust the point where two-digits years are mapped to 2000's or 1900's. create_iso8601(years, .format = \"y\", .cutoff_2000 = 20L) #> [1] NA NA \"2000\" \"2001\" \"2015\" \"1930\" \"1950\" \"1968\" \"1969\" \"1980\" #> [11] \"1999\" # Both numeric months (two-digit only) and abbreviated months work out of the box months <- c(\"0\", \"00\", \"1\", \"01\", \"Jan\", \"jan\") create_iso8601(months, .format = \"m\") #> [1] NA \"--00\" NA \"--01\" \"--01\" \"--01\" # Month days: single or two-digit numbers, anything else results in NA. create_iso8601(c(\"1\", \"01\", \"001\", \"10\", \"20\", \"31\"), .format = \"d\") #> [1] \"----01\" \"----01\" NA \"----10\" \"----20\" \"----31\" # Hours create_iso8601(c(\"1\", \"01\", \"001\", \"10\", \"20\", \"31\"), .format = \"H\") #> [1] \"-----T01\" \"-----T01\" NA \"-----T10\" \"-----T20\" \"-----T31\" # Minutes create_iso8601(c(\"1\", \"01\", \"001\", \"10\", \"20\", \"60\"), .format = \"M\") #> [1] \"-----T-:01\" \"-----T-:01\" NA \"-----T-:10\" \"-----T-:20\" #> [6] \"-----T-:60\" # Seconds create_iso8601(c(\"1\", \"01\", \"23.04\", \"001\", \"10\", \"20\", \"60\"), .format = \"S\") #> [1] \"-----T-:-:01\" \"-----T-:-:01\" \"-----T-:-:23.04\" NA #> [5] \"-----T-:-:10\" \"-----T-:-:20\" \"-----T-:-:60\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"allowing-alternative-date-or-time-values","dir":"Articles","previous_headings":"","what":"Allowing alternative date or time values","title":"Converting dates, times or date-times to ISO 8601","text":"date time component values include special values, e.g. values encoding missing values, can indicate values possible alternatives parsing tolerate ; use .na argument: case achieve result using regexps:","code":"create_iso8601(\"U DEC 2019 14:00\", .format = \"d m y H:M\") #> [1] NA create_iso8601(\"U DEC 2019 14:00\", .format = \"d m y H:M\", .na = \"U\") #> [1] \"2019-12--T14:00\" create_iso8601(\"U UNK 2019 14:00\", .format = \"d m y H:M\") #> [1] NA create_iso8601(\"U UNK 2019 14:00\", .format = \"d m y H:M\", .na = c(\"U\", \"UNK\")) #> [1] \"2019----T14:00\" create_iso8601(\"U UNK 2019 14:00\", .format = \"(d|U) (m|UNK) y H:M\") #> [1] \"2019----T14:00\""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/iso_8601.html","id":"changing-reserved-format-characters","dir":"Articles","previous_headings":"","what":"Changing reserved format characters","title":"Converting dates, times or date-times to ISO 8601","text":"might cases reserved characters — \"y\", \"m\", \"d\", \"H\", \"M\", \"S\" — might get way specifying adequate format. example, might tempted use format \"HHMM\" try parse time \"14H00M\". assume first “H” codes parsing hour, second “H” literal “H” , actually, \"HH\" taken mean parsing hours, \"MM\" parse minutes. can use function fmt_cmp() specify alternative format regexps format, replacing default characters. next example, reassign new format strings hour minute components, thus freeing \"H\" \"M\" patterns interpreted hours minutes, taken literally: Note need make sure format component regexps mutually exclusive, .e. don’t overlapping matches; otherwise create_iso8601() fail error. next example months minutes represented \"m\" format resulting ambiguous format specification.","code":"create_iso8601(\"14H00M\", .format = \"HHMM\") #> [1] NA create_iso8601(\"14H00M\", .format = \"xHwM\", .fmt_c = fmt_cmp(hour = \"x\", min = \"w\")) #> [1] \"-----T14:00\" fmt_cmp(hour = \"h\", min = \"m\") #> $sec #> [1] \"S+\" #> #> $min #> [1] \"m\" #> #> $hour #> [1] \"h\" #> #> $mday #> [1] \"d+\" #> #> $mon #> [1] \"m+\" #> #> $year #> [1] \"y+\" #> #> attr(,\"class\") #> [1] \"fmt_c\" try(create_iso8601(\"14H00M\", .format = \"hHmM\", .fmt_c = fmt_cmp(hour = \"h\", min = \"m\"))) #> Error in purrr::map2(dots, .format, ~parse_dttm(dttm = .x, fmt = .y, na = .na, : #> ℹ In index: 1. #> Caused by error in `purrr::map()` at sdtm.oak/R/dtc_parse_dttm.R:104:3: #> ℹ In index: 1. #> Caused by error in `parse_dttm_fmt()` at sdtm.oak/R/parse_dttm_fmt.R:442:3: #> ! Patterns in `fmt_c` have overlapping matches."},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/study_sdtm_spec.html","id":"standards-metadata","dir":"Articles","previous_headings":"","what":"Standards Metadata","title":"All about Metadata","text":"standards metadata used {sdtm.oak} sourced CDISC Library sponsor MDR form documentation standards maintained. metadata provides information following: relationship Data Collection Standards (eCRF & eDT), SDTM mapping, Controlled Terminology Machine-readable standard SDTM mappings Algorithms associated metadata required SDTM automation standards study. upcoming releases {sdtm.oak}, effectively utilize standards metadata customize meet study requirements.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/study_sdtm_spec.html","id":"study-definition-metadata","dir":"Articles","previous_headings":"","what":"Study Definition Metadata","title":"All about Metadata","text":"Study Definition Metadata also referred Study Metadata. Study Definition Metadata provides information eCRF eDT data collected study. eCRF Metadata eCRF Design Metadata fetched EDC system. Metadata includes Forms Metadata: Identifier, eCRF label, Repeating format properties eCRF. Fields Metadata: Identifier, question label, datatype, properties data collection fields study. Data Dictionaries: Identifier controlled terms collected source. Visits: Name visits defined EDC. eDT Metadata eDT Metadata blueprint metadata describes data collected part external data transfer (clinical sites sponsor). includes Dataset name, label, repeating properties, etc. Variable name, datatype, label associated codelist, etc.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/articles/study_sdtm_spec.html","id":"study-sdtm-mappings-metadata-specifications","dir":"Articles","previous_headings":"","what":"Study SDTM Mappings Metadata (specifications)","title":"All about Metadata","text":"Study SDTM mappings metadata study SDTM specification. develop SDTM domains, {sdtm.oak} requires user prepare Study SDTM mappings metadata. Unlike conventional SDTM specification, includes one tab per domain defining target (SDTM domain, Variables) source (raw dataset, raw variables) SDTM mappings, SDTM spec {sdtm.oak} defines source--target relationship. source, SDTM mapping, algorithms, associated metadata defined. table presents columns SDTM mapping specification explanation.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Rammprasad Ganapathy. Author, maintainer. Adam Forys. Author. Edgar Manukyan. Author. Rosemary Li. Author. Preetesh Parikh. Author. Lisa Houterloot. Author. Yogesh Gupta. Author. Omar Garcia. Author. Ramiro Magno. Author. Pattern Institute. Copyright holder, funder. F. Hoffmann-La Roche AG. Copyright holder, funder. Pfizer Inc. Copyright holder, funder.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Ganapathy R, Forys , Manukyan E, Li R, Parikh P, Houterloot L, Gupta Y, Garcia O, Magno R (2024). sdtm.oak: SDTM Data Transformation Engine. R package version 0.0.0.9003, https://github.com/pharmaverse/sdtm.oak, https://pharmaverse.github.io/sdtm.oak/.","code":"@Manual{, title = {sdtm.oak: SDTM Data Transformation Engine}, author = {Rammprasad Ganapathy and Adam Forys and Edgar Manukyan and Rosemary Li and Preetesh Parikh and Lisa Houterloot and Yogesh Gupta and Omar Garcia and Ramiro Magno}, year = {2024}, note = {R package version 0.0.0.9003, https://github.com/pharmaverse/sdtm.oak}, url = {https://pharmaverse.github.io/sdtm.oak/}, }"},{"path":"https://pharmaverse.github.io/sdtm.oak/index.html","id":"sdtmoak-","dir":"","previous_headings":"","what":"SDTM Data Transformation Engine","title":"SDTM Data Transformation Engine","text":"EDC Data Standard agnostic solution enables pharmaceutical programming community develop SDTM datasets R. reusable algorithms concept sdtm.oak provides framework modular programming also can automate SDTM creation based standard SDTM spec.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"SDTM Data Transformation Engine","text":"can install development version sdtm.oak GitHub :","code":"# install.packages(\"remotes\") remotes::install_github(\"pharmaverse/sdtm.oak\")"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":null,"dir":"Reference","previous_headings":"","what":"Add ISO 8601 parsing problems — add_problems","title":"Add ISO 8601 parsing problems — add_problems","text":"add_problems() annotates returned value create_iso8601() possible parsing problems. annotation consists tibble problems, one row parsing failure (see Details section).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add ISO 8601 parsing problems — add_problems","text":"","code":"add_problems(x, is_problem, dtc)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add ISO 8601 parsing problems — add_problems","text":"x character vector date-times ISO 8601 format; typically, output format_iso8601(). is_problem logical indicating date/time inputs associated parsing failures. dtc list character vectors dates, times date-times' components. Typically, parameter takes value passed ... create_iso8601() call.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add ISO 8601 parsing problems — add_problems","text":"Either x without modification, parsing problems exist, annotated x, meaning problems attribute holds parsing issues (see Details section).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add ISO 8601 parsing problems — add_problems","text":"function annotates input x, vector date-times ISO 8601 format, creating attribute named problems. attribute's value tibble parsing problems. problematic date/times indicated logical vector passed argument is_problem. attribute problems returned value contain first column named ..indicates date/time index problematic date/time x, many extra columns inputs (passed dtc). dtc named, names used name extra columns, otherwise get named sequentially like ..var1, ..var2, etc..","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/add_problems.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add ISO 8601 parsing problems — add_problems","text":"","code":"date <- c(\"2000-01-05\", \"\", \"1980-06-18\", \"1979-09-07\") time <- c(\"001221\", \"22:35:05\", \"03:00:15\", \"07:09:00\") dtc <- list(date, time) dttm <- c(\"2000-01-05\", \"T22:35:05\", \"1980-06-18T03:00:15\", \"1979-09-07T07:09:00\") is_problem <- c(TRUE, TRUE, FALSE, FALSE) dttm2 <- sdtm.oak:::add_problems(dttm, is_problem, dtc) sdtm.oak:::problems(dttm2) #> # A tibble: 2 × 3 #> ..i ..var1 ..var2 #> #> 1 1 \"2000-01-05\" 001221 #> 2 2 \"\" 22:35:05"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":null,"dir":"Reference","previous_headings":"","what":"Detect problems with the parsing of date/times — any_problems","title":"Detect problems with the parsing of date/times — any_problems","text":"any_problems() takes list capture matrices (see parse_dttm()) reports parsing problems means predicate values. FALSE value indicates parsing successful TRUE value parsing failure least one inputs create_iso8601(). Note internal function used context create_iso8601() source code hence capture matrix corresponds one input create_iso8601().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Detect problems with the parsing of date/times — any_problems","text":"","code":"any_problems(cap_matrices, .cutoff_2000 = 68L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Detect problems with the parsing of date/times — any_problems","text":"cap_matrices list capture matrices sense returned value parse_dttm(). .cutoff_2000 integer value. Two-digit years smaller equal .cutoff_2000 parsed though starting 20, otherwise parsed though starting 19.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Detect problems with the parsing of date/times — any_problems","text":"logical whose length matches number underlying date/times passed inputs create_iso8601(), .e. whose length matches number rows capture matrices cap_matrices.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/any_problems.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Detect problems with the parsing of date/times — any_problems","text":"","code":"# No problem (return value is `FALSE`). sdtm.oak:::any_problems(list(sdtm.oak:::parse_dttm(\"1980-06-18\", \"y-m-d\"))) #> [1] FALSE # Now the parsing fails (return value is `TRUE`). sdtm.oak:::any_problems(list(sdtm.oak:::parse_dttm(\"1980-06-18\", \"ymd\"))) #> [1] TRUE # Find if there has been a problem in either in the `date` or `time` inputs. # The following problems are expected with: # - `\"2001/12/25\"` as it won't be parsed with the format `\"y-m-d\"` # - `\"00h12m21\"` as it won't be parsed with the format `\"H:M:S\"`. # date <- c(\"2000-01-05\", \"2001/12/25\", \"1980-06-18\", \"1979-09-07\") time <- c(\"00h12m21\", \"22:35:05\", \"03:00:15\", \"07:09:00\") cap_matrix_date <- sdtm.oak:::parse_dttm(date, \"y-m-d\") cap_matrix_time <- sdtm.oak:::parse_dttm(time, \"H:M:S\") (cap_matrices <- list(cap_matrix_date, cap_matrix_time)) #> [[1]] #> year mon mday hour min sec #> [1,] \"2000\" \"01\" \"05\" NA NA NA #> [2,] NA NA NA NA NA NA #> [3,] \"1980\" \"06\" \"18\" NA NA NA #> [4,] \"1979\" \"09\" \"07\" NA NA NA #> #> [[2]] #> year mon mday hour min sec #> [1,] NA NA NA NA NA NA #> [2,] NA NA NA \"22\" \"35\" \"05\" #> [3,] NA NA NA \"03\" \"00\" \"15\" #> [4,] NA NA NA \"07\" \"09\" \"00\" #> # `any_problems()` returns `TRUE` for the first two elements because of the # failure to parse `\"2001/12/25\"` and `\"00h12m21\"`, respectively. sdtm.oak:::any_problems(cap_matrices) #> [1] TRUE TRUE FALSE FALSE"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert capture matrix — assert_capture_matrix","title":"Assert capture matrix — assert_capture_matrix","text":"assert_capture_matrix() internal helper function aiding checking internal R object contains parsing results returned parse_dttm(): capture matrix. function checks capture matrix matrix contains six columns: year, mon, mday, hour, min sec.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert capture matrix — assert_capture_matrix","text":"","code":"assert_capture_matrix(m)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert capture matrix — assert_capture_matrix","text":"m character matrix.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assert capture matrix — assert_capture_matrix","text":"function throws error m either: character matrix; matrix whose columns (least): year, mon, mday, hour, min sec. Otherwise, returns m invisibly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_capture_matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert capture matrix — assert_capture_matrix","text":"","code":"cols <- c(\"year\", \"mon\", \"mday\", \"hour\", \"min\", \"sec\") m <- matrix(NA_character_, nrow = 1L, ncol = 6L, dimnames = list(NULL, cols)) sdtm.oak:::assert_capture_matrix(m) # These commands should throw an error if (FALSE) { sdtm.oak:::assert_capture_matrix(character()) sdtm.oak:::assert_capture_matrix(matrix(data = NA_character_, nrow = 0, ncol = 0)) sdtm.oak:::assert_capture_matrix(matrix(data = NA_character_, nrow = 1)) }"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert a codelist code — assert_ct_clst","title":"Assert a codelist code — assert_ct_clst","text":"assert_ct_clst() asserts validity codelist code context controlled terminology specification.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert a codelist code — assert_ct_clst","text":"","code":"assert_ct_clst(ct_spec, ct_clst, optional = FALSE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert a codelist code — assert_ct_clst","text":"ct_spec Either data frame encoding controlled terminology data set, NULL. ct_clst string -asserted codelist code, NULL. optional scalar logical, indicating whether ct_clst can NULL .","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assert a codelist code — assert_ct_clst","text":"function throws error ct_clst valid codelist code given controlled terminology data set; otherwise, ct_clst returned invisibly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_clst.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert a codelist code — assert_ct_clst","text":"","code":"# Load a controlled terminology example. (ct_spec <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # Should work fine. sdtm.oak:::assert_ct_clst(ct_spec = ct_spec, ct_clst = \"C71113\") #> [1] \"C71113\" # In certain cases, you might allow `ct_clst` to be `NULL` as to indicate absence, # in that case, set `optional` to `TRUE` to make `assert_ct_clst()` more # forgiving. sdtm.oak:::assert_ct_clst(ct_spec = ct_spec, ct_clst = NULL, optional = TRUE) # Otherwise it would err. try(sdtm.oak:::assert_ct_clst(ct_spec = ct_spec, ct_clst = NULL, optional = FALSE)) #> Error in sdtm.oak:::assert_ct_clst(ct_spec = ct_spec, ct_clst = NULL, : #> `ct_clst` is a required parameter."},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert a controlled terminology specification — assert_ct_spec","title":"Assert a controlled terminology specification — assert_ct_spec","text":"assert_ct_spec() check whether ct_spec data frame contains variables: codelist_code, collected_value, term_synonyms, term_value. addition, also check data frame empty (rows), whether columns codelist_code term_value contain NA values.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert a controlled terminology specification — assert_ct_spec","text":"","code":"assert_ct_spec(ct_spec, optional = FALSE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert a controlled terminology specification — assert_ct_spec","text":"ct_spec data frame asserted valid controlled terminology data set.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assert a controlled terminology specification — assert_ct_spec","text":"function throws error ct_spec valid controlled terminology data set; otherwise, ct_spec returned invisibly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_ct_spec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert a controlled terminology specification — assert_ct_spec","text":"","code":"# If `ct_spec` is a valid controlled terminology then it is returned invisibly. ct_spec_01 <- read_ct_spec_example(\"ct-01-cm\") all.equal(ct_spec_01, sdtm.oak:::assert_ct_spec(ct_spec_01)) #> [1] TRUE # A minimal set of variables needs to be present in `ct_spec` for it to pass the # assertion; `sdtm.oak:::ct_spec_vars()` defines their names. (req_vars <- sdtm.oak:::ct_spec_vars()) #> [1] \"codelist_code\" \"collected_value\" \"term_synonyms\" \"term_value\" # Other (facultative) variables also present in the controlled terminology # example. (opt_vars <- setdiff(colnames(ct_spec_01), req_vars)) #> [1] \"term_code\" \"CodedData\" \"term_preferred_term\" #> [4] \"raw_codelist\" # With only the mandatory variables, the assertion still passes. sdtm.oak:::assert_ct_spec(ct_spec_01[req_vars]) # Not having the required variables results in an error. try(sdtm.oak:::assert_ct_spec(ct_spec_01[opt_vars])) #> Error in sdtm.oak:::assert_ct_spec(ct_spec_01[opt_vars]) : #> Required variables `codelist_code`, `collected_value`, `term_synonyms`, #> and `term_value` are missing in `ct_spec`"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_fmt.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert date time character formats — assert_dtc_fmt","title":"Assert date time character formats — assert_dtc_fmt","text":"assert_dtc_fmt() takes character vector date/time formats checks formats supported, meaning checks one formats listed column fmt dtc_formats, failing error otherwise.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_fmt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert date time character formats — assert_dtc_fmt","text":"","code":"assert_dtc_fmt(fmt)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_fmt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert date time character formats — assert_dtc_fmt","text":"fmt character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_fmt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert date time character formats — assert_dtc_fmt","text":"","code":"sdtm.oak:::assert_dtc_fmt(c(\"ymd\", \"y m d\", \"dmy\", \"HM\", \"H:M:S\", \"y-m-d H:M:S\")) #> [1] \"ymd\" \"y m d\" \"dmy\" \"HM\" \"H:M:S\" #> [6] \"y-m-d H:M:S\" # This example is guarded to avoid throwing errors if (FALSE) { sdtm.oak:::assert_dtc_fmt(\"y years m months d days\") }"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":null,"dir":"Reference","previous_headings":"","what":"Assert dtc format — assert_dtc_format","title":"Assert dtc format — assert_dtc_format","text":"assert_dtc_format() internal helper function aiding checking .format parameter create_iso8601().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Assert dtc format — assert_dtc_format","text":"","code":"assert_dtc_format(.format)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Assert dtc format — assert_dtc_format","text":".format argument create_iso8601()'s .format parameter.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Assert dtc format — assert_dtc_format","text":"function throws error .format either: character vector formats permitted assert_dtc_fmt(); list character vectors formats permitted assert_dtc_fmt(). Otherwise, returns .format invisibly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assert_dtc_format.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Assert dtc format — assert_dtc_format","text":"","code":"sdtm.oak:::assert_dtc_format(\"ymd\") sdtm.oak:::assert_dtc_format(c(\"ymd\", \"y-m-d\")) sdtm.oak:::assert_dtc_format(list(c(\"ymd\", \"y-m-d\"), \"H:M:S\")) # These commands should throw an error if (FALSE) { # Note that `\"year, month, day\"` is not a supported format. sdtm.oak:::assert_dtc_format(\"year, month, day\") }"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an SDTM variable — assign_no_ct","title":"Derive an SDTM variable — assign_no_ct","text":"assign_no_ct() maps variable raw dataset target SDTM variable terminology restrictions. assign_ct() maps variable raw dataset target SDTM variable following controlled terminology recoding.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an SDTM variable — assign_no_ct","text":"","code":"assign_no_ct( raw_dat, raw_var, tgt_var, tgt_dat = NULL, id_vars = oak_id_vars() ) assign_ct( raw_dat, raw_var, tgt_var, ct_spec, ct_clst, tgt_dat = NULL, id_vars = oak_id_vars() )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an SDTM variable — assign_no_ct","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable: single string indicating name raw variable raw_dat. tgt_var target SDTM variable: single string indicating name variable derived. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (raw_dat). ct_spec Study controlled terminology specification: dataframe minimal set columns, see ct_spec_vars() details. ct_clst codelist code indicating subset controlled terminology apply derivation.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an SDTM variable — assign_no_ct","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Derive an SDTM variable — assign_no_ct","text":"","code":"md1 <- tibble::tibble( oak_id = 1:14, raw_source = \"MD1\", patient_number = 101:114, MDIND = c( \"NAUSEA\", \"NAUSEA\", \"ANEMIA\", \"NAUSEA\", \"PYREXIA\", \"VOMITINGS\", \"DIARHHEA\", \"COLD\", \"FEVER\", \"LEG PAIN\", \"FEVER\", \"COLD\", \"COLD\", \"PAIN\" ) ) assign_no_ct( raw_dat = md1, raw_var = \"MDIND\", tgt_var = \"CMINDC\", ) #> # A tibble: 14 × 4 #> oak_id raw_source patient_number CMINDC #> #> 1 1 MD1 101 NAUSEA #> 2 2 MD1 102 NAUSEA #> 3 3 MD1 103 ANEMIA #> 4 4 MD1 104 NAUSEA #> 5 5 MD1 105 PYREXIA #> 6 6 MD1 106 VOMITINGS #> 7 7 MD1 107 DIARHHEA #> 8 8 MD1 108 COLD #> 9 9 MD1 109 FEVER #> 10 10 MD1 110 LEG PAIN #> 11 11 MD1 111 FEVER #> 12 12 MD1 112 COLD #> 13 13 MD1 113 COLD #> 14 14 MD1 114 PAIN cm_inter <- tibble::tibble( oak_id = 1:14, raw_source = \"MD1\", patient_number = 101:114, CMTRT = c( \"BABY ASPIRIN\", \"CORTISPORIN\", \"ASPIRIN\", \"DIPHENHYDRAMINE HCL\", \"PARCETEMOL\", \"VOMIKIND\", \"ZENFLOX OZ\", \"AMITRYPTYLINE\", \"BENADRYL\", \"DIPHENHYDRAMINE HYDROCHLORIDE\", \"TETRACYCLINE\", \"BENADRYL\", \"SOMINEX\", \"ZQUILL\" ), CMROUTE = c( \"ORAL\", \"ORAL\", NA, \"ORAL\", \"ORAL\", \"ORAL\", \"INTRAMUSCULAR\", \"INTRA-ARTERIAL\", NA, \"NON-STANDARD\", \"RANDOM_VALUE\", \"INTRA-ARTICULAR\", \"TRANSDERMAL\", \"OPHTHALMIC\" ) ) # Controlled terminology specification (ct_spec <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist assign_ct( raw_dat = md1, raw_var = \"MDIND\", tgt_var = \"CMINDC\", ct_spec = ct_spec, ct_clst = \"C66729\", tgt_dat = cm_inter ) #> # A tibble: 14 × 6 #> oak_id raw_source patient_number CMTRT CMROUTE CMINDC #> #> 1 1 MD1 101 BABY ASPIRIN ORAL NAUSEA #> 2 2 MD1 102 CORTISPORIN ORAL NAUSEA #> 3 3 MD1 103 ASPIRIN NA ANEMIA #> 4 4 MD1 104 DIPHENHYDRAMINE HCL ORAL NAUSEA #> 5 5 MD1 105 PARCETEMOL ORAL PYREX… #> 6 6 MD1 106 VOMIKIND ORAL VOMIT… #> 7 7 MD1 107 ZENFLOX OZ INTRAM… DIARH… #> 8 8 MD1 108 AMITRYPTYLINE INTRA-… COLD #> 9 9 MD1 109 BENADRYL NA FEVER #> 10 10 MD1 110 DIPHENHYDRAMINE HYDROCHLORIDE NON-ST… LEG P… #> 11 11 MD1 111 TETRACYCLINE RANDOM… FEVER #> 12 12 MD1 112 BENADRYL INTRA-… COLD #> 13 13 MD1 113 SOMINEX TRANSD… COLD #> 14 14 MD1 114 ZQUILL OPHTHA… PAIN"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an ISO8601 date-time variable — assign_datetime","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"assign_datetime() maps one variables date/time components raw dataset target SDTM variable following ISO8601 format.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"","code":"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 )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable(s): character vector indicating name(s) raw variable(s) raw_dat date time components parsed ISO8601 format variable tgt_var. raw_fmt date/time parsing format. Either character vector list character vectors. character vector passed element taken parsing format variable indicated raw_var. list provided, element must character vector formats. first vector formats used parsing first variable raw_var, . tgt_var target SDTM variable: single string indicating name variable derived. raw_unk character vector string literals regarded missing values parsing. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (tgt_dat). .warn Whether warn parsing failures.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/assign_datetime.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Derive an ISO8601 date-time variable — assign_datetime","text":"","code":"# `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 #> #> 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 #> #> 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 #> #> 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 #> #> 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 #> #> 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 #> #> 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"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/clear_cache.html","id":null,"dir":"Reference","previous_headings":"","what":"Clear {sdtm.oak} cache of memoised functions — clear_cache","title":"Clear {sdtm.oak} cache of memoised functions — clear_cache","text":"{sdtm.oak} functions results cached runtime efficiency. Use function reset cache. Memoised functions: ct_mappings()","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/clear_cache.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Clear {sdtm.oak} cache of memoised functions — clear_cache","text":"","code":"clear_cache()"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/clear_cache.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Clear {sdtm.oak} cache of memoised functions — clear_cache","text":"Returns logical value, indicating whether resetting cache successful (TRUE) (FALSE).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/clear_cache.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Clear {sdtm.oak} cache of memoised functions — clear_cache","text":"","code":"clear_cache() #> [1] TRUE"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":null,"dir":"Reference","previous_headings":"","what":"Coalesce capture matrices — coalesce_capture_matrices","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"coalesce_capture_matrices() combines several capture matrices one. argument ... capture matrix sense output complete_capture_matrix(), meaning character matrix six columns whose names : year, mon, mday, hour, min sec.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"","code":"coalesce_capture_matrices(...)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"... sequence capture matrices.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"single capture matrix whose values coalesced sense coalesce().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/coalesce_capture_matrices.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Coalesce capture matrices — coalesce_capture_matrices","text":"","code":"cols <- c(\"year\", \"mon\", \"mday\", \"hour\", \"min\", \"sec\") dates <- c(\"2020\", \"01\", \"01\", \"20\", NA, NA) times <- c(NA, NA, NA, \"10\", \"00\", \"05\") m_dates <- matrix(dates, nrow = 1L, ncol = 6L, dimnames = list(NULL, cols)) m_times <- matrix(times, nrow = 1L, ncol = 6L, dimnames = list(NULL, cols)) # Note how the hour \"20\" takes precedence over \"10\" sdtm.oak:::coalesce_capture_matrices(m_dates, m_times) #> year mon mday hour min sec #> [1,] \"2020\" \"01\" \"01\" \"20\" \"00\" \"05\" # Reverse the order of the inputs and now hour \"10\" takes precedence sdtm.oak:::coalesce_capture_matrices(m_times, m_dates) #> year mon mday hour min sec #> [1,] \"2020\" \"01\" \"01\" \"10\" \"00\" \"05\" # Single inputs should result in the same output as the input sdtm.oak:::coalesce_capture_matrices(m_dates) #> year mon mday hour min sec #> [1,] \"2020\" \"01\" \"01\" \"20\" NA NA sdtm.oak:::coalesce_capture_matrices(m_times) #> year mon mday hour min sec #> [1,] NA NA NA \"10\" \"00\" \"05\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Complete a capture matrix — complete_capture_matrix","title":"Complete a capture matrix — complete_capture_matrix","text":"complete_capture_matrix() completes missing, , columns capture matrix.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Complete a capture matrix — complete_capture_matrix","text":"","code":"complete_capture_matrix(m)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Complete a capture matrix — complete_capture_matrix","text":"m character matrix might missing one following columns: year, mon, mday, hour, min sec.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Complete a capture matrix — complete_capture_matrix","text":"character matrix contains columns year, mon, mday, hour, min sec. existing columns dropped.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/complete_capture_matrix.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Complete a capture matrix — complete_capture_matrix","text":"","code":"sdtm.oak:::complete_capture_matrix(matrix(data = NA_character_, nrow = 0, ncol = 0)) sdtm.oak:::complete_capture_matrix(matrix(data = NA_character_, nrow = 1)) # m <- matrix(NA_character_, nrow = 1, ncol = 2, dimnames = list(NULL, c(\"year\", \"sec\"))) # sdtm.oak:::complete_capture_matrix(m) # m <- matrix(c(\"2020\", \"10\"), nrow = 1, ncol = 2, dimnames = list(NULL, c(\"year\", \"sec\"))) # sdtm.oak:::complete_capture_matrix(m) # Any other existing columns are dropped. # m <- matrix(c(\"2020\", \"10\"), nrow = 1, ncol = 2, dimnames = list(NULL, c(\"semester\", \"quarter\"))) # sdtm.oak:::complete_capture_matrix(m)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"contains_oak_id_vars() evaluates whether character vector x contains raw dataset key variable names, .e. called Oak identifier variables --- defined return value oak_id_vars().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"","code":"contains_oak_id_vars(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"logical scalar value.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/contains_oak_id_vars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Does a vector contain the raw dataset key variables? — contains_oak_id_vars","text":"","code":"# `oak_id_vars()` is the function that defines what are the minimal set of # oak keys. Hence, by definition, the following code should always return # `TRUE`. sdtm.oak:::contains_oak_id_vars(sdtm.oak:::oak_id_vars()) #> [1] TRUE # Returns `FALSE`. sdtm.oak:::contains_oak_id_vars(character()) #> [1] FALSE # Another example that returns `FALSE` because it is missing # `\"patient_number\"`. sdtm.oak:::contains_oak_id_vars(c(\"oak_id\", \"raw_source\")) #> [1] FALSE"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/create_iso8601.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert date or time collected values to ISO 8601 — create_iso8601","title":"Convert date or time collected values to ISO 8601 — create_iso8601","text":"create_iso8601() converts vectors dates, times date-times ISO 8601 format. Learn vignette(\"iso_8601\").","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/create_iso8601.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert date or time collected values to ISO 8601 — create_iso8601","text":"","code":"create_iso8601( ..., .format, .fmt_c = fmt_cmp(), .na = NULL, .cutoff_2000 = 68L, .check_format = FALSE, .warn = TRUE )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/create_iso8601.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert date or time collected values to ISO 8601 — create_iso8601","text":"... Character vectors dates, times date-times' components. .format Parsing format(s). Either character vector list character vectors. character vector passed element taken parsing format vector passed .... list provided, element must character vector formats. first vector formats used parsing first vector passed ..., . .fmt_c list regexps use parsing .format. Use fmt_cmp() create object pass argument parameter. .na character vector string literals regarded missing values parsing. .cutoff_2000 integer value. Two-digit years smaller equal .cutoff_2000 parsed though starting 20, otherwise parsed though starting 19. .check_format Whether check formats passed .format, meaning check selection validated formats dtc_formats; permissible interpretation formats. .warn Whether warn parsing failures.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/create_iso8601.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert date or time collected values to ISO 8601 — create_iso8601","text":"","code":"# Converting dates create_iso8601(c(\"2020-01-01\", \"20200102\"), .format = \"y-m-d\") #> [1] \"2020-01-01\" NA create_iso8601(c(\"2020-01-01\", \"20200102\"), .format = \"ymd\") #> [1] NA \"2020-01-02\" create_iso8601(c(\"2020-01-01\", \"20200102\"), .format = list(c(\"y-m-d\", \"ymd\"))) #> [1] \"2020-01-01\" \"2020-01-02\" # Two-digit years are supported create_iso8601(c(\"20-01-01\", \"200101\"), .format = list(c(\"y-m-d\", \"ymd\"))) #> [1] \"2020-01-01\" \"2020-01-01\" # `.cutoff_2000` sets the cutoff for two-digit to four-digit year conversion # Default is at 68. create_iso8601(c(\"67-01-01\", \"68-01-01\", \"69-01-01\"), .format = \"y-m-d\") #> [1] \"2067-01-01\" \"2068-01-01\" \"1969-01-01\" # Change it to 80. create_iso8601(c(\"79-01-01\", \"80-01-01\", \"81-01-01\"), .format = \"y-m-d\", .cutoff_2000 = 80) #> [1] \"2079-01-01\" \"2080-01-01\" \"1981-01-01\" # Converting times create_iso8601(\"15:10\", .format = \"HH:MM\") #> [1] \"-----T15:10\" create_iso8601(\"2:10\", .format = \"HH:MM\") #> [1] \"-----T02:10\" create_iso8601(\"2:1\", .format = \"HH:MM\") #> [1] \"-----T02:01\" create_iso8601(\"02:01:56\", .format = \"HH:MM:SS\") #> [1] \"-----T02:01:56\" create_iso8601(\"020156.5\", .format = \"HHMMSS\") #> [1] \"-----T02:01:56.5\" # Converting date-times create_iso8601(\"12 NOV 202015:15\", .format = \"dd mmm yyyyHH:MM\") #> [1] \"2020-11-12T15:15\" # Indicate allowed missing values to make the parsing pass create_iso8601(\"U DEC 201914:00\", .format = \"dd mmm yyyyHH:MM\") #> [1] NA create_iso8601(\"U DEC 201914:00\", .format = \"dd mmm yyyyHH:MM\", .na = \"U\") #> [1] \"2019-12--T14:00\" create_iso8601(\"NOV 2020\", .format = \"m y\") #> [1] \"2020-11\" create_iso8601(c(\"MAR 2019\", \"MaR 2020\", \"mar 2021\"), .format = \"m y\") #> [1] \"2019-03\" \"2020-03\" \"2021-03\" create_iso8601(\"2019-04-041045-\", .format = \"yyyy-mm-ddHHMM-\") #> [1] \"2019-04-04T10:45\" create_iso8601(\"20200507null\", .format = \"ymd(HH:MM:SS)\") #> [1] NA create_iso8601(\"20200507null\", .format = \"ymd((HH:MM:SS)|null)\") #> [1] \"2020-05-07\" # Fractional seconds create_iso8601(\"2019-120602:20:13.1230001\", .format = \"y-mdH:M:S\") #> [1] \"2019-12-06T02:20:13.1230001\" # Use different reserved characters in the format specification # Here we change \"H\" to \"x\" and \"M\" to \"w\", for hour and minute, respectively. create_iso8601(\"14H00M\", .format = \"HHMM\") #> [1] NA create_iso8601(\"14H00M\", .format = \"xHwM\", .fmt_c = fmt_cmp(hour = \"x\", min = \"w\")) #> [1] \"-----T14:00\" # Alternative formats with unknown values datetimes <- c(\"UN UNK 201914:00\", \"UN JAN 2021\") format <- list(c(\"dd mmm yyyy\", \"dd mmm yyyyHH:MM\")) create_iso8601(datetimes, .format = format, .na = c(\"UN\", \"UNK\")) #> [1] \"2019----T14:00\" \"2021-01\" # Dates and times may come in many format variations fmt <- \"dd MMM yyyy HH nn ss\" fmt_cmp <- fmt_cmp(mon = \"MMM\", min = \"nn\", sec = \"ss\") create_iso8601(\"05 feb 1985 12 55 02\", .format = fmt, .fmt_c = fmt_cmp) #> [1] \"1985-02-05T12:55:02\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":null,"dir":"Reference","previous_headings":"","what":"Recode according to controlled terminology — ct_map","title":"Recode according to controlled terminology — ct_map","text":"ct_map() recodes vector following controlled terminology.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Recode according to controlled terminology — ct_map","text":"","code":"ct_map( x, ct_spec = NULL, ct_clst = NULL, from = ct_spec_vars(\"from\"), to = ct_spec_vars(\"to\") )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Recode according to controlled terminology — ct_map","text":"x character vector terms recoded following controlled terminology. ct_spec tibble providing controlled terminology specification. ct_clst character vector indicating set possible controlled terminology codelists codes used recoding. default (NULL) codelists available ct_spec used. character vector column names indicating variables containing values matched terminology recoding. single string indicating column whose values recoded .","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Recode according to controlled terminology — ct_map","text":"character vector terminology recoded values x. match found controlled terminology spec provided ct_spec, x values returned uppercase. ct_spec provided x returned unchanged.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_map.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Recode according to controlled terminology — ct_map","text":"","code":"# A few example terms. terms <- c( \"/day\", \"Yes\", \"Unknown\", \"Prior\", \"Every 2 hours\", \"Percentage\", \"International Unit\" ) # Load a controlled terminology example (ct_spec <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # Use all possible matching terms in the controlled terminology. ct_map(x = terms, ct_spec = ct_spec) #> [1] \"QD\" \"Y\" \"UNKNOWN\" \"BEFORE\" \"Q2H\" \"%\" \"IU\" # Note that if the controlled terminology mapping is restricted to a codelist # code, e.g. C71113, then only `\"/day\"` and `\"Every 2 hours\"` get mapped to # `\"QD\"` and `\"Q2H\"`, respectively; remaining terms won't match given the # codelist code restriction, and will be mapped to an uppercase version of # the original terms. ct_map(x = terms, ct_spec = ct_spec, ct_clst = \"C71113\") #> [1] \"QD\" \"YES\" \"UNKNOWN\" #> [4] \"PRIOR\" \"Q2H\" \"PERCENTAGE\" #> [7] \"INTERNATIONAL UNIT\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":null,"dir":"Reference","previous_headings":"","what":"Controlled terminology mappings — ct_mappings","title":"Controlled terminology mappings — ct_mappings","text":"ct_mappings() takes controlled terminology specification returns mappings form tibble long format, .e. recoding values column column values, one mapping per row. resulting mappings unique, .e. values duplicated two columns, first column indicated takes precedence, mapping retained controlled terminology map.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Controlled terminology mappings — ct_mappings","text":"","code":"ct_mappings(ct_spec, from = ct_spec_vars(\"from\"), to = ct_spec_vars(\"to\"))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Controlled terminology mappings — ct_mappings","text":"ct_spec Controlled terminology specification tibble. row mapped controlled term. Controlled terms expected column indicated to_col. character vector column names indicating variables containing values recoded. single string indicating column whose values recoded .","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Controlled terminology mappings — ct_mappings","text":"tibble two columns, , indicating mapping values, one per row.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_mappings.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Controlled terminology mappings — ct_mappings","text":"","code":"# Read in a bundled controlled terminology spec example (ex. 01). (ct_spec_01 <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # Generate mappings from the terminology specification. sdtm.oak:::ct_mappings(ct_spec = ct_spec_01) #> # A tibble: 79 × 2 #> from to #> #> 1 QD QD #> 2 BID BID #> 3 PRN PRN #> 4 Q2H Q2H #> 5 QID QID #> 6 CAPSULE CAPSULE #> 7 PILL PILL #> 8 LOTION LOTION #> 9 AEROSOL AEROSOL #> 10 INHALANT INHALANT #> # ℹ 69 more rows # Take a glimpse at those mappings where an actual recoding happens. sdtm.oak:::ct_mappings(ct_spec = ct_spec_01) |> dplyr::filter(from != to) |> print(n = 20) #> # A tibble: 49 × 2 #> from to #> #> 1 QD (Every Day) QD #> 2 BID (Twice a Day) BID #> 3 PRN (As Needed) PRN #> 4 Q2H (Every 2 Hours) Q2H #> 5 QID (4 Times a Day) QID #> 6 Capsule CAPSULE #> 7 Pill PILL #> 8 Lotion LOTION #> 9 Aerosol AEROSOL #> 10 Inhalant INHALANT #> 11 Injection INJECTION #> 12 Liquid LIQUID #> 13 Tablet TABLET #> 14 Yes Y #> 15 IM (Intramuscular) INTRAMUSCULAR #> 16 EP (Epidural) EPIDURAL #> 17 IA (Intra-arterial) INTRA-ARTERIAL #> 18 IJ (Intra-articular) INTRA-ARTICULAR #> 19 OP (Ophthalmic) OPHTHALMIC #> 20 PO (Oral) ORAL #> # ℹ 29 more rows"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":null,"dir":"Reference","previous_headings":"","what":"Find the path to an example controlled terminology file — ct_spec_example","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"ct_spec_example() resolves local path example controlled terminology file.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"","code":"ct_spec_example(example)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"example string either basename, file name, relative path controlled terminology file bundled {stdm.oak}, see examples.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"local path example file example supplied, character vector example file names.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_example.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Find the path to an example controlled terminology file — ct_spec_example","text":"","code":"# Get the local path to controlled terminology example file 01 # Using the basename only: ct_spec_example(\"ct-01-cm\") #> [1] \"/renv/lib/R-4.3/x86_64-pc-linux-gnu/sdtm.oak/ct/ct-01-cm.csv\" # Using the file name: ct_spec_example(\"ct-01-cm.csv\") #> [1] \"/renv/lib/R-4.3/x86_64-pc-linux-gnu/sdtm.oak/ct/ct-01-cm.csv\" # Using the relative path: ct_spec_example(\"ct/ct-01-cm.csv\") #> [1] \"/renv/lib/R-4.3/x86_64-pc-linux-gnu/sdtm.oak/ct/ct-01-cm.csv\" # If no example is provided it returns a vector of possible choices. ct_spec_example() #> [1] \"ct-01-cm.csv\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Controlled terminology variables — ct_spec_vars","title":"Controlled terminology variables — ct_spec_vars","text":"ct_spec_vars() returns mandatory variables present data set representing controlled terminology. default, returns required variables. subset variables used matching terms needed, request subset variables passing argument value \"\". mapping-variable requested, simply pass \"\". codelist code variable name needed pass \"ct_clst\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Controlled terminology variables — ct_spec_vars","text":"","code":"ct_spec_vars(set = c(\"all\", \"ct_clst\", \"from\", \"to\"))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Controlled terminology variables — ct_spec_vars","text":"set scalar character (string), one : \"\" (default), \"ct_clst\", \"\" \"\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/ct_spec_vars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Controlled terminology variables — ct_spec_vars","text":"","code":"# These two calls are equivalent and return all required variables in a # controlled terminology data set. ct_spec_vars() #> [1] \"codelist_code\" \"collected_value\" \"term_synonyms\" \"term_value\" ct_spec_vars(\"all\") #> [1] \"codelist_code\" \"collected_value\" \"term_synonyms\" \"term_value\" # \"Codelist code\" variable name. ct_spec_vars(\"ct_clst\") #> [1] \"codelist_code\" # \"From\" variables ct_spec_vars(\"from\") #> [1] \"collected_value\" \"term_synonyms\" # The \"to\" variable. ct_spec_vars(\"to\") #> [1] \"term_value\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":null,"dir":"Reference","previous_headings":"","what":"derive_study_day performs study day calculation — derive_study_day","title":"derive_study_day performs study day calculation — derive_study_day","text":"function takes input data frame reference data frame (DM domain cases), calculate study day reference date target date. case unexpected conditions like reference date unique patient, reference input dates actual dates, NA returned records.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"derive_study_day performs study day calculation — derive_study_day","text":"","code":"derive_study_day( sdtm_in, dm_domain, tgdt, refdt, study_day_var, merge_key = \"USUBJID\" )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"derive_study_day performs study day calculation — derive_study_day","text":"sdtm_in Input data frame contains target date. dm_domain Reference date frame contains reference date. tgdt Target date sdtm_in used calculate study day. refdt Reference date dm_domain used reference calculate study day. study_day_var New study day variable name output. example, AESTDY AE domain CMSTDY CM domain. merge_key Character represent merging key sdtm_in dm_domain.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"derive_study_day performs study day calculation — derive_study_day","text":"Data frame takes columns sdtm_in new variable represent calculated study day.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/derive_study_day.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"derive_study_day performs study day calculation — derive_study_day","text":"","code":"ae <- data.frame( USUBJID = c(\"study123-123\", \"study123-124\", \"study123-125\"), AESTDTC = c(\"2012-01-01\", \"2012-04-14\", \"2012-04-14\") ) dm <- data.frame( USUBJID = c(\"study123-123\", \"study123-124\", \"study123-125\"), RFSTDTC = c(\"2012-02-01\", \"2012-04-14\", NA) ) ae$AESTDTC <- as.Date(ae$AESTDTC) dm$RFSTDTC <- as.Date(dm$RFSTDTC) derive_study_day(ae, dm, \"AESTDTC\", \"RFSTDTC\", \"AESTDY\") #> USUBJID AESTDTC AESTDY #> 1 study123-123 2012-01-01 -31 #> 2 study123-124 2012-04-14 1 #> 3 study123-125 2012-04-14 NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dtc_formats.html","id":null,"dir":"Reference","previous_headings":"","what":"Date/time collection formats — dtc_formats","title":"Date/time collection formats — dtc_formats","text":"Date/time collection formats","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dtc_formats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Date/time collection formats — dtc_formats","text":"","code":"dtc_formats"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dtc_formats.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"Date/time collection formats — dtc_formats","text":"tibble 20 formats three variables: fmt Format string. type Whether date, time date-time. description Description date-time components parsed.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dtc_formats.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Date/time collection formats — dtc_formats","text":"","code":"dtc_formats #> # A tibble: 20 × 3 #> fmt type description #> #> 1 ymd date Parses a date: year, month, and month day. #> 2 y m d date Parses a date: year, month, and month day. #> 3 y-m-d date Parses a date: year, month, and month day. #> 4 dmy date Parses a date: month day, month and year. #> 5 d m y date Parses a date: month day, month and year. #> 6 d-m-y date Parses a date: month day, month and year. #> 7 ym date Parses a date: year and month. #> 8 y m date Parses a date: year and month. #> 9 y-m date Parses a date: year and month. #> 10 my date Parses a date: month and year. #> 11 m y date Parses a date: month and year. #> 12 m-y date Parses a date: month and year. #> 13 HM time Parses a time: hour and minutes. #> 14 HMS time Parses a time: hour, minutes, and seconds. #> 15 H:M time Parses a time: hour and minutes. #> 16 H:M:S time Parses a time: hour, minutes and seconds. #> 17 ymdH:M:S datetime Parses a date-time: year, month, month day, hour, minut… #> 18 ymd H:M:S datetime Parses a date-time: year, month, month day, hour, minut… #> 19 y-m-d H:M:S datetime Parses a date-time: year, month, month day, hour, minut… #> 20 y m d H:M:S datetime Parses a date-time: year, month, month day, hour, minut…"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"dttm_fmt_to_regex() takes tibble parsed date/time format components (returned parse_dttm_fmt()), mapping date/time component formats regexps generates single regular expression groups matching date/time components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"","code":"dttm_fmt_to_regex( fmt, fmt_regex = fmt_rg(), fmt_c = fmt_cmp(), anchored = TRUE )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"fmt format string (scalar) parsed patterns. fmt_regex named character vector regexps, one date/time component. anchored Whether final regex anchored, .e. bounded \"^\" \"$\" whole match.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"string containing regular expression matching date/time components according format.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/dttm_fmt_to_regex.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a parsed date/time format to regex — dttm_fmt_to_regex","text":"","code":"sdtm.oak:::dttm_fmt_to_regex(\"y\") #> ^(?(\\d{2})?\\d{2})$ sdtm.oak:::dttm_fmt_to_regex(\"y\", anchored = FALSE) #> [1] \"(?(\\\\d{2})?\\\\d{2})\" sdtm.oak:::dttm_fmt_to_regex(\"m\") #> ^(?\\d\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])$ sdtm.oak:::dttm_fmt_to_regex(\"ymd\") #> ^(?(\\d{2})?\\d{2})(?\\d\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])(?\\b\\d|\\d{2})$ sdtm.oak:::dttm_fmt_to_regex(\"ymd HH:MM:SS\") #> ^(?(\\d{2})?\\d{2})(?\\d\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])(?\\b\\d|\\d{2}) (?\\d?\\d):(?(\\b\\d|\\d{2})):(?(\\b\\d|\\d{2})(\\.\\d*)?)$"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/find_int_gap.html","id":null,"dir":"Reference","previous_headings":"","what":"Find gap intervals in integer sequences — find_int_gap","title":"Find gap intervals in integer sequences — find_int_gap","text":"find_int_gap() determines start end positions gap intervals sequence integers. default, interval range look gaps defined minimum maximum values x; specify xmin xmax change range explicitly.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/find_int_gap.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Find gap intervals in integer sequences — find_int_gap","text":"","code":"find_int_gap(x, xmin = min(x), xmax = max(x))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/find_int_gap.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Find gap intervals in integer sequences — find_int_gap","text":"x integer vector. xmin Left endpoint integer value. xmax Right endpoint integer value.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/find_int_gap.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Find gap intervals in integer sequences — find_int_gap","text":"tibble gap intervals two columns: start: left endpoint end: right endpoint gap intervals found empty tibble returned.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":null,"dir":"Reference","previous_headings":"","what":"Regexps for date/time format components — fmt_cmp","title":"Regexps for date/time format components — fmt_cmp","text":"fmt_cmp() creates character vector patterns match individual format date/time components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regexps for date/time format components — fmt_cmp","text":"","code":"fmt_cmp( sec = \"S+\", min = \"M+\", hour = \"H+\", mday = \"d+\", mon = \"m+\", year = \"y+\" )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regexps for date/time format components — fmt_cmp","text":"sec string pattern matching second format component. min string pattern matching minute format component. hour string pattern matching hour format component. mday string pattern matching month day format component. mon string pattern matching month format component. year string pattern matching year format component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regexps for date/time format components — fmt_cmp","text":"named character vector date/time format patterns. vector six elements, one date/time component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_cmp.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Regexps for date/time format components — fmt_cmp","text":"","code":"# Regexps to parse format components fmt_cmp() #> $sec #> [1] \"S+\" #> #> $min #> [1] \"M+\" #> #> $hour #> [1] \"H+\" #> #> $mday #> [1] \"d+\" #> #> $mon #> [1] \"m+\" #> #> $year #> [1] \"y+\" #> #> attr(,\"class\") #> [1] \"fmt_c\" fmt_cmp(year = \"yyyy\") #> $sec #> [1] \"S+\" #> #> $min #> [1] \"M+\" #> #> $hour #> [1] \"H+\" #> #> $mday #> [1] \"d+\" #> #> $mon #> [1] \"m+\" #> #> $year #> [1] \"yyyy\" #> #> attr(,\"class\") #> [1] \"fmt_c\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":null,"dir":"Reference","previous_headings":"","what":"Regexps for date/time components — fmt_rg","title":"Regexps for date/time components — fmt_rg","text":"fmt_rg() creates character vector named patterns match individual date/time components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regexps for date/time components — fmt_rg","text":"","code":"fmt_rg( sec = \"(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?\", min = \"(\\\\b\\\\d|\\\\d{2})\", hour = \"\\\\d?\\\\d\", mday = \"\\\\b\\\\d|\\\\d{2}\", mon = stringr::str_glue(\"\\\\d\\\\d|{months_abb_regex()}\"), year = \"(\\\\d{2})?\\\\d{2}\", na = NULL, sec_na = na, min_na = na, hour_na = na, mday_na = na, mon_na = na, year_na = na )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regexps for date/time components — fmt_rg","text":"sec Regexp second component. min Regexp minute component. hour Regexp hour component. mday Regexp month day component. mon Regexp month component. year Regexp year component. na Regexp alternatives, useful match special values coding missingness. sec_na na specifically second component. min_na na specifically minute component. hour_na na specifically hour component. mday_na na specifically month day component. mon_na na specifically month component. year_na na specifically year component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regexps for date/time components — fmt_rg","text":"named character vector named patterns (regexps) matching date/time component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/fmt_rg.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Regexps for date/time components — fmt_rg","text":"","code":"# Default regexps sdtm.oak:::fmt_rg() #> sec #> \"(?(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?)\" #> min #> \"(?(\\\\b\\\\d|\\\\d{2}))\" #> hour #> \"(?\\\\d?\\\\d)\" #> mday #> \"(?\\\\b\\\\d|\\\\d{2})\" #> mon #> \"(?\\\\d\\\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])\" #> year #> \"(?(\\\\d{2})?\\\\d{2})\" # You may change the way months are matched, e.g. you might not want to match # month abbreviations, i.e. only numerical months. So pass an explicit regex # for numerical months: sdtm.oak:::fmt_rg(mon = r\"[\\b\\d|\\d{2}]\") #> sec min #> \"(?(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?)\" \"(?(\\\\b\\\\d|\\\\d{2}))\" #> hour mday #> \"(?\\\\d?\\\\d)\" \"(?\\\\b\\\\d|\\\\d{2})\" #> mon year #> \"(?\\\\b\\\\d|\\\\d{2})\" \"(?(\\\\d{2})?\\\\d{2})\" # Make date/time components accept `\"UNK\"` as a possible pattern (useful # to match funny codes for `NA`). sdtm.oak:::fmt_rg(na = \"UNK\") #> sec #> \"(?(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?|UNK)\" #> min #> \"(?(\\\\b\\\\d|\\\\d{2})|UNK)\" #> hour #> \"(?\\\\d?\\\\d|UNK)\" #> mday #> \"(?\\\\b\\\\d|\\\\d{2}|UNK)\" #> mon #> \"(?\\\\d\\\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc]|UNK)\" #> year #> \"(?(\\\\d{2})?\\\\d{2}|UNK)\" # Or be more specific and use `\"UNK\"` for the year component only. sdtm.oak:::fmt_rg(year_na = \"UNK\") #> sec #> \"(?(\\\\b\\\\d|\\\\d{2})(\\\\.\\\\d*)?)\" #> min #> \"(?(\\\\b\\\\d|\\\\d{2}))\" #> hour #> \"(?\\\\d?\\\\d)\" #> mday #> \"(?\\\\b\\\\d|\\\\d{2})\" #> mon #> \"(?\\\\d\\\\d|[Jj][Aa][Nn]|[Ff][Ee][Bb]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][Uu][Ll]|[Aa][Uu][Gg]|[Ss][Ee][Pp]|[Oo][Cc][Tt]|[Nn][Oo][Vv]|[Dd][Ee][Cc])\" #> year #> \"(?(\\\\d{2})?\\\\d{2}|UNK)\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert date/time components into ISO8601 format — format_iso8601","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"format_iso8601() takes character matrix date/time components converts component ISO8601 format. practice entails converting years four digit number, month, day, hours, minutes seconds two-digit numbers. available (NA) components converted \"-\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"","code":"format_iso8601(m, .cutoff_2000 = 68L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"m character matrix date/time components. must six named columns: year, mon, mday, hour, min sec. .cutoff_2000 integer value. Two-digit years smaller equal .cutoff_2000 parsed though starting 20, otherwise parsed though starting 19.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"character vector date-times following ISO8601 format.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/format_iso8601.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert date/time components into ISO8601 format — format_iso8601","text":"","code":"cols <- c(\"year\", \"mon\", \"mday\", \"hour\", \"min\", \"sec\") m <- matrix( c( \"99\", \"00\", \"01\", \"Jan\", \"feb\", \"03\", \"1\", \"01\", \"31\", \"00\", \"12\", \"23\", \"00\", \"59\", \"10\", \"42\", \"5.15\", NA ), ncol = 6, dimnames = list(c(), cols) ) sdtm.oak:::format_iso8601(m) #> [1] \"1999-01-01T00:00:42\" \"2000-02-01T12:59:05.15\" \"2001-03-31T23:10\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an SDTM variable with a hardcoded value — harcode","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"hardcode_no_ct() maps hardcoded value target SDTM variable terminology restrictions. hardcode_ct() maps hardcoded value target SDTM variable controlled terminology recoding.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"","code":"hardcode_no_ct( raw_dat, raw_var, tgt_var, tgt_val, tgt_dat = NULL, id_vars = oak_id_vars() ) hardcode_ct( raw_dat, raw_var, tgt_var, tgt_val, ct_spec, ct_clst, tgt_dat = NULL, id_vars = oak_id_vars() )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable: single string indicating name raw variable raw_dat. tgt_var target SDTM variable: single string indicating name variable derived. tgt_val target SDTM value hardcoded variable indicated tgt_var. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (raw_dat). ct_spec Study controlled terminology specification: dataframe minimal set columns, see ct_spec_vars() details. parameter optional, left NULL controlled terminology recoding applied. ct_clst codelist code indicating subset controlled terminology apply derivation. parameter optional, left NULL, possible recodings ct_spec attempted.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/harcode.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Derive an SDTM variable with a hardcoded value — harcode","text":"","code":"md1 <- tibble::tribble( ~oak_id, ~raw_source, ~patient_number, ~MDRAW, 1L, \"MD1\", 101L, \"BABY ASPIRIN\", 2L, \"MD1\", 102L, \"CORTISPORIN\", 3L, \"MD1\", 103L, NA_character_, 4L, \"MD1\", 104L, \"DIPHENHYDRAMINE HCL\" ) # Derive a new variable `CMCAT` by overwriting `MDRAW` with the # hardcoded value \"GENERAL CONCOMITANT MEDICATIONS\". hardcode_no_ct( raw_dat = md1, raw_var = \"MDRAW\", tgt_var = \"CMCAT\", tgt_val = \"GENERAL CONCOMITANT MEDICATIONS\" ) #> # A tibble: 4 × 4 #> oak_id raw_source patient_number CMCAT #> #> 1 1 MD1 101 GENERAL CONCOMITANT MEDICATIONS #> 2 2 MD1 102 GENERAL CONCOMITANT MEDICATIONS #> 3 3 MD1 103 NA #> 4 4 MD1 104 GENERAL CONCOMITANT MEDICATIONS cm_inter <- tibble::tribble( ~oak_id, ~raw_source, ~patient_number, ~CMTRT, ~CMINDC, 1L, \"MD1\", 101L, \"BABY ASPIRIN\", NA, 2L, \"MD1\", 102L, \"CORTISPORIN\", \"NAUSEA\", 3L, \"MD1\", 103L, \"ASPIRIN\", \"ANEMIA\", 4L, \"MD1\", 104L, \"DIPHENHYDRAMINE HCL\", \"NAUSEA\", 5L, \"MD1\", 105L, \"PARACETAMOL\", \"PYREXIA\" ) # Derive a new variable `CMCAT` by overwriting `MDRAW` with the # hardcoded value \"GENERAL CONCOMITANT MEDICATIONS\" with a prior join to # `target_dataset`. hardcode_no_ct( raw_dat = md1, raw_var = \"MDRAW\", tgt_var = \"CMCAT\", tgt_val = \"GENERAL CONCOMITANT MEDICATIONS\", tgt_dat = cm_inter ) #> # A tibble: 5 × 6 #> oak_id raw_source patient_number CMTRT CMINDC CMCAT #> #> 1 1 MD1 101 BABY ASPIRIN NA GENERAL CONCOMIT… #> 2 2 MD1 102 CORTISPORIN NAUSEA GENERAL CONCOMIT… #> 3 3 MD1 103 ASPIRIN ANEMIA NA #> 4 4 MD1 104 DIPHENHYDRAMINE HCL NAUSEA GENERAL CONCOMIT… #> 5 5 MD1 105 PARACETAMOL PYREXIA NA # Controlled terminology specification (ct_spec <- read_ct_spec_example(\"ct-01-cm\")) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # Hardcoding of `CMCAT` with the value `\"GENERAL CONCOMITANT MEDICATIONS\"` # involving terminology recoding. `NA` values in `MDRAW` are preserved in # `CMCAT`. hardcode_ct( raw_dat = md1, raw_var = \"MDRAW\", tgt_var = \"CMCAT\", tgt_val = \"GENERAL CONCOMITANT MEDICATIONS\", ct_spec = ct_spec, ct_clst = \"C66729\", tgt_dat = cm_inter ) #> # A tibble: 5 × 6 #> oak_id raw_source patient_number CMTRT CMINDC CMCAT #> #> 1 1 MD1 101 BABY ASPIRIN NA GENERAL CONCOMIT… #> 2 2 MD1 102 CORTISPORIN NAUSEA GENERAL CONCOMIT… #> 3 3 MD1 103 ASPIRIN ANEMIA NA #> 4 4 MD1 104 DIPHENHYDRAMINE HCL NAUSEA GENERAL CONCOMIT… #> 5 5 MD1 105 PARACETAMOL PYREXIA NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":null,"dir":"Reference","previous_headings":"","what":"Determine Indices for Recoding — index_for_recode","title":"Determine Indices for Recoding — index_for_recode","text":"index_for_recode() identifies positions elements x match values specified vector. function primarily used facilitate recoding values pinpointing elements x correspond values thus need replaced updated.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Determine Indices for Recoding — index_for_recode","text":"","code":"index_for_recode(x, from)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Determine Indices for Recoding — index_for_recode","text":"x vector values search matches. vector values match elements x.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Determine Indices for Recoding — index_for_recode","text":"integer vector length x, containing indices matched values vector. element x match value , corresponding position output NA. index information critical subsequent recoding operations.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/index_for_recode.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Determine Indices for Recoding — index_for_recode","text":"","code":"sdtm.oak:::index_for_recode(x = 1:5, from = c(2, 4)) #> [1] NA 1 NA 2 NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":null,"dir":"Reference","previous_headings":"","what":"Format as a ISO8601 month — iso8601_mon","title":"Format as a ISO8601 month — iso8601_mon","text":"iso8601_mon() converts character vector whose values represent numeric abbreviated month names zero-padded numeric months.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format as a ISO8601 month — iso8601_mon","text":"","code":"iso8601_mon(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format as a ISO8601 month — iso8601_mon","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format as a ISO8601 month — iso8601_mon","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_mon.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format as a ISO8601 month — iso8601_mon","text":"","code":"sdtm.oak:::iso8601_mon(c(NA, \"0\", \"1\", \"2\", \"10\", \"11\", \"12\")) #> [1] NA \"00\" \"01\" \"02\" \"10\" \"11\" \"12\" # No semantic validation is performed on the numeric months, so `\"13\"` stays # `\"13\"` but representations that can't be represented as two-digit numbers # become `NA`. sdtm.oak:::iso8601_mon(c(\"13\", \"99\", \"100\", \"-1\")) #> [1] \"13\" \"99\" NA NA (mon <- month.abb) #> [1] \"Jan\" \"Feb\" \"Mar\" \"Apr\" \"May\" \"Jun\" \"Jul\" \"Aug\" \"Sep\" \"Oct\" \"Nov\" \"Dec\" sdtm.oak:::iso8601_mon(mon) #> [1] \"01\" \"02\" \"03\" \"04\" \"05\" \"06\" \"07\" \"08\" \"09\" \"10\" \"11\" \"12\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert NA to ","title":"Convert NA to ","text":"iso8601_na() takes character vector converts NA values \"-\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert NA to ","text":"","code":"iso8601_na(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert NA to ","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert NA to ","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_na.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert NA to ","text":"","code":"sdtm.oak:::iso8601_na(c(\"10\", NA_character_)) #> [1] \"10\" \"-\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":null,"dir":"Reference","previous_headings":"","what":"Format as ISO8601 seconds — iso8601_sec","title":"Format as ISO8601 seconds — iso8601_sec","text":"iso8601_sec() converts character vector whose values represent seconds.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format as ISO8601 seconds — iso8601_sec","text":"","code":"iso8601_sec(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format as ISO8601 seconds — iso8601_sec","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format as ISO8601 seconds — iso8601_sec","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_sec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format as ISO8601 seconds — iso8601_sec","text":"","code":"sdtm.oak:::iso8601_sec(c(NA, \"0\", \"1\", \"10\", \"59\", \"99\", \"100\")) #> [1] NA \"00\" \"01\" \"10\" \"59\" \"99\" NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":null,"dir":"Reference","previous_headings":"","what":"Truncate a partial ISO8601 date-time — iso8601_truncate","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"iso8601_truncate() converts character vector ISO8601 dates, times date-times might partial truncates format removing missing components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"","code":"iso8601_truncate(x, empty_as_na = TRUE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_truncate.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Truncate a partial ISO8601 date-time — iso8601_truncate","text":"","code":"x <- c( \"1999-01-01T15:20:01\", \"1999-01-01T15:20:-\", \"1999-01-01T15:-:-\", \"1999-01-01T-:-:-\", \"1999-01--T-:-:-\", \"1999----T-:-:-\", \"-----T-:-:-\" ) sdtm.oak:::iso8601_truncate(x) #> [1] \"1999-01-01T15:20:01\" \"1999-01-01T15:20\" \"1999-01-01T15\" #> [4] \"1999-01-01\" \"1999-01\" \"1999\" #> [7] NA # With `empty_as_na = FALSE` empty strings are not replaced with `NA` sdtm.oak:::iso8601_truncate(\"-----T-:-:-\", empty_as_na = TRUE) #> [1] NA sdtm.oak:::iso8601_truncate(\"-----T-:-:-\", empty_as_na = FALSE) #> [1] \"\" # Truncation only happens if missing components are the right most end, # otherwise they remain unaltered. sdtm.oak:::iso8601_truncate( c( \"1999----T15:20:01\", \"1999-01-01T-:20:01\", \"1999-01-01T-:-:01\", \"1999-01-01T-:-:-\" ) ) #> [1] \"1999----T15:20:01\" \"1999-01-01T-:20:01\" \"1999-01-01T-:-:01\" #> [4] \"1999-01-01\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":null,"dir":"Reference","previous_headings":"","what":"Format as a ISO8601 two-digit number — iso8601_two_digits","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"iso8601_two_digits() converts single digit two digit number two digit, 0-padded, number. Failing parse input two digit number results NA.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"","code":"iso8601_two_digits(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"x character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"character vector size x.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_two_digits.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format as a ISO8601 two-digit number — iso8601_two_digits","text":"","code":"x <- c(\"0\", \"00\", \"1\", \"01\", \"42\", \"100\", NA_character_, \"1.\") sdtm.oak:::iso8601_two_digits(x) #> [1] \"00\" \"00\" \"01\" \"01\" \"42\" NA NA NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":null,"dir":"Reference","previous_headings":"","what":"Format as a ISO8601 four-digit year — iso8601_year","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"iso8601_year() converts character vector whose values represent years four-digit years.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"","code":"iso8601_year(x, cutoff_2000 = 68L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"x character vector. cutoff_2000 non-negative integer value. Two-digit years smaller equal cutoff_2000 parsed though starting 20, otherwise parsed though starting 19.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/iso8601_year.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Format as a ISO8601 four-digit year — iso8601_year","text":"","code":"sdtm.oak:::iso8601_year(c(\"0\", \"1\", \"2\", \"50\", \"68\", \"69\", \"90\", \"99\", \"00\")) #> [1] \"2000\" \"2001\" \"2002\" \"2050\" \"2068\" \"1969\" \"1990\" \"1999\" \"2000\" # Be default, `cutoff_2000` is at 68. sdtm.oak:::iso8601_year(c(\"67\", \"68\", \"69\", \"70\")) #> [1] \"2067\" \"2068\" \"1969\" \"1970\" sdtm.oak:::iso8601_year(c(\"1967\", \"1968\", \"1969\", \"1970\")) #> [1] \"1967\" \"1968\" \"1969\" \"1970\" # Change it to something else, e.g. `cutoff_2000 = 25`. sdtm.oak:::iso8601_year(as.character(0:50), cutoff_2000 = 25) #> [1] \"2000\" \"2001\" \"2002\" \"2003\" \"2004\" \"2005\" \"2006\" \"2007\" \"2008\" \"2009\" #> [11] \"2010\" \"2011\" \"2012\" \"2013\" \"2014\" \"2015\" \"2016\" \"2017\" \"2018\" \"2019\" #> [21] \"2020\" \"2021\" \"2022\" \"2023\" \"2024\" \"2025\" \"1926\" \"1927\" \"1928\" \"1929\" #> [31] \"1930\" \"1931\" \"1932\" \"1933\" \"1934\" \"1935\" \"1936\" \"1937\" \"1938\" \"1939\" #> [41] \"1940\" \"1941\" \"1942\" \"1943\" \"1944\" \"1945\" \"1946\" \"1947\" \"1948\" \"1949\" #> [51] \"1950\" sdtm.oak:::iso8601_year(as.character(1900:1950), cutoff_2000 = 25) #> [1] \"1900\" \"1901\" \"1902\" \"1903\" \"1904\" \"1905\" \"1906\" \"1907\" \"1908\" \"1909\" #> [11] \"1910\" \"1911\" \"1912\" \"1913\" \"1914\" \"1915\" \"1916\" \"1917\" \"1918\" \"1919\" #> [21] \"1920\" \"1921\" \"1922\" \"1923\" \"1924\" \"1925\" \"1926\" \"1927\" \"1928\" \"1929\" #> [31] \"1930\" \"1931\" \"1932\" \"1933\" \"1934\" \"1935\" \"1936\" \"1937\" \"1938\" \"1939\" #> [41] \"1940\" \"1941\" \"1942\" \"1943\" \"1944\" \"1945\" \"1946\" \"1947\" \"1948\" \"1949\" #> [51] \"1950\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/months_abb_regex.html","id":null,"dir":"Reference","previous_headings":"","what":"Regex for months' abbreviations — months_abb_regex","title":"Regex for months' abbreviations — months_abb_regex","text":"months_abb_regex() generates regex matches month abbreviations. finer control, case can specified parameter case.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/months_abb_regex.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Regex for months' abbreviations — months_abb_regex","text":"","code":"months_abb_regex(x = month.abb, case = c(\"any\", \"upper\", \"lower\", \"title\"))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/months_abb_regex.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Regex for months' abbreviations — months_abb_regex","text":"x character vector three-letter month abbreviations. Default month.abb. case string scalar: \"\", month abbreviations matched case; \"upper\", match uppercase abbreviations; \"lower\", match lowercase; , \"title\" match title case.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/months_abb_regex.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Regex for months' abbreviations — months_abb_regex","text":"regex string.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":null,"dir":"Reference","previous_headings":"","what":"Raw dataset keys — oak_id_vars","title":"Raw dataset keys — oak_id_vars","text":"oak_id_vars() helper function providing variable (column) names regarded keys tibbles representing raw datasets. default, set names oak_id, raw_source, patient_number. Extra variable names may indicated passed extra_vars appended default names.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Raw dataset keys — oak_id_vars","text":"","code":"oak_id_vars(extra_vars = NULL)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Raw dataset keys — oak_id_vars","text":"extra_vars character vector extra column names appended default names: oak_id, raw_source, patient_number.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Raw dataset keys — oak_id_vars","text":"character vector column names regarded keys raw datasets.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/oak_id_vars.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Raw dataset keys — oak_id_vars","text":"","code":"sdtm.oak:::oak_id_vars() #> [1] \"oak_id\" \"raw_source\" \"patient_number\" sdtm.oak:::oak_id_vars(extra_vars = \"sample_id\") #> [1] \"oak_id\" \"raw_source\" \"patient_number\" \"sample_id\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse a date, time, or date-time — parse_dttm_","title":"Parse a date, time, or date-time — parse_dttm_","text":"parse_dttm() extracts date time components. parse_dttm() wraps around parse_dttm_(), vectorized fmt.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse a date, time, or date-time — parse_dttm_","text":"","code":"parse_dttm_( dttm, fmt, fmt_c = fmt_cmp(), na = NULL, sec_na = na, min_na = na, hour_na = na, mday_na = na, mon_na = na, year_na = na ) parse_dttm( dttm, fmt, fmt_c = fmt_cmp(), na = NULL, sec_na = na, min_na = na, hour_na = na, mday_na = na, mon_na = na, year_na = na )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse a date, time, or date-time — parse_dttm_","text":"dttm character vector dates, times date-times. fmt case parse_dttm(), character vector parsing formats, single string format case parse_dttm_(). character vector formats passed, format attempted turn first parsing result successful taking precedence final result. formats fmt can strings, however following characters (successive repetitions thereof) reserved sense treated special way: \"y\": parsed year; \"m\": parsed month; \"d\": parsed day; \"H\": parsed hour; \"M\": parsed minute; \"S\": parsed second. na, sec_na, min_na, hour_na, mday_na, mon_na, year_na character vector alternative values allow matching. can used indicate different forms missing values found parsing date-time strings.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse a date, time, or date-time — parse_dttm_","text":"character matrix six columns: \"year\", \"mon\", \"mday\", \"hour\", \"min\" \"sec\". row corresponds element dttm. element matrix parsed date/time component.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Parse a date, time, or date-time — parse_dttm_","text":"","code":"sdtm.oak:::parse_dttm(\"2020\", \"y\") #> year mon mday hour min sec #> [1,] \"2020\" NA NA NA NA NA sdtm.oak:::parse_dttm(\"2020-05\", \"y\") #> year mon mday hour min sec #> [1,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(\"2020-05\", \"y-m\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" NA NA NA NA sdtm.oak:::parse_dttm(\"2020-05-11\", \"y-m-d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" NA NA NA sdtm.oak:::parse_dttm(\"2020 05 11\", \"y m d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" NA NA NA sdtm.oak:::parse_dttm(\"2020 05 11\", \"y m d\") #> year mon mday hour min sec #> [1,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(\"2020 05 11\", \"y\\\\s+m\\\\s+d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" NA NA NA sdtm.oak:::parse_dttm(\"2020 05 11\", \"y\\\\s+m\\\\s+d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" NA NA NA sdtm.oak:::parse_dttm(\"2020-05-11 11:45\", \"y-m-d H:M\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" \"11\" \"45\" NA sdtm.oak:::parse_dttm(\"2020-05-11 11:45:15.6\", \"y-m-d H:M:S\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"11\" \"11\" \"45\" \"15.6\" sdtm.oak:::parse_dttm(c(\"2002-05-11 11:45\", \"-05-11 11:45\"), \"y-m-d H:M\") #> year mon mday hour min sec #> [1,] \"2002\" \"05\" \"11\" \"11\" \"45\" NA #> [2,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(c(\"2002-05-11 11:45\", \"-05-11 11:45\"), \"-m-d H:M\") #> year mon mday hour min sec #> [1,] NA NA NA NA NA NA #> [2,] NA \"05\" \"11\" \"11\" \"45\" NA sdtm.oak:::parse_dttm(c(\"2002-05-11 11:45\", \"-05-11 11:45\"), c(\"y-m-d H:M\", \"-m-d H:M\")) #> year mon mday hour min sec #> [1,] \"2002\" \"05\" \"11\" \"11\" \"45\" NA #> [2,] NA \"05\" \"11\" \"11\" \"45\" NA sdtm.oak:::parse_dttm(\"05 feb 1985 12 55 02\", \"d m y H M S\") #> year mon mday hour min sec #> [1,] \"1985\" \"feb\" \"05\" \"12\" \"55\" \"02\" sdtm.oak:::parse_dttm(\"12 55 02 05 feb 1985\", \"H M S d m y\") #> year mon mday hour min sec #> [1,] \"1985\" \"feb\" \"05\" \"12\" \"55\" \"02\" sdtm.oak:::parse_dttm(c(\"2020-05-18\", \"2020-UN-18\", \"2020-UNK-UN\"), \"y-m-d\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"18\" NA NA NA #> [2,] NA NA NA NA NA NA #> [3,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(c(\"2020-05-18\", \"2020-UN-18\", \"2020-UNK-UN\"), \"y-m-d\", na = \"UN\") #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"18\" NA NA NA #> [2,] \"2020\" \"UN\" \"18\" NA NA NA #> [3,] NA NA NA NA NA NA sdtm.oak:::parse_dttm(c(\"2020-05-18\", \"2020-UN-18\", \"2020-UNK-UN\"), \"y-m-d\", na = c(\"UN\", \"UNK\")) #> year mon mday hour min sec #> [1,] \"2020\" \"05\" \"18\" NA NA NA #> [2,] \"2020\" \"UN\" \"18\" NA NA NA #> [3,] \"2020\" \"UNK\" \"UN\" NA NA NA"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":null,"dir":"Reference","previous_headings":"","what":"Parse a date/time format — parse_dttm_fmt_","title":"Parse a date/time format — parse_dttm_fmt_","text":"parse_dttm_fmt() parses date/time formats, meaning try parse components format fmt refer date/time components. parse_dttm_fmt_() similar parse_dttm_fmt() vectorized fmt.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parse a date/time format — parse_dttm_fmt_","text":"","code":"parse_dttm_fmt_(fmt, pattern) parse_dttm_fmt(fmt, patterns = fmt_cmp())"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parse a date/time format — parse_dttm_fmt_","text":"fmt format string (scalar) parsed patterns. pattern, patterns string (case pattern), character vector (case patterns) regexps individual date/time components. Default value fmt_cmp(). Use function plan passing different set patterns.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parse a date/time format — parse_dttm_fmt_","text":"tibble seven columns: fmt_c: date/time format component. Values either \"year\", \"mon\", \"mday\", \"hour\", \"min\", \"sec\", NA. pat: Regexp used parse date/time component. cap: captured substring format. start: Start position format string capture. end: End position format string capture. len: Length capture (number chars). ord: Ordinal date/time component format string. row either date/time format component \"delimiter\" string pattern -format components.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/parse_dttm_fmt.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Parse a date/time format — parse_dttm_fmt_","text":"","code":"sdtm.oak:::parse_dttm_fmt(\"ymd\") #> # A tibble: 3 × 7 #> fmt_c pat cap start end len ord #> #> 1 year y+ y 1 1 1 1 #> 2 mon m+ m 2 2 1 2 #> 3 mday d+ d 3 3 1 3 sdtm.oak:::parse_dttm_fmt(\"H:M:S\") #> # A tibble: 5 × 7 #> fmt_c pat cap start end len ord #> #> 1 hour H+ H 1 1 1 1 #> 2 NA NA : 2 2 1 NA #> 3 min M+ M 3 3 1 2 #> 4 NA NA : 4 4 1 NA #> 5 sec S+ S 5 5 1 3 sdtm.oak:::parse_dttm_fmt(\"ymd HMS\") #> # A tibble: 7 × 7 #> fmt_c pat cap start end len ord #> #> 1 year y+ \"y\" 1 1 1 1 #> 2 mon m+ \"m\" 2 2 1 2 #> 3 mday d+ \"d\" 3 3 1 3 #> 4 NA NA \" \" 4 4 1 NA #> 5 hour H+ \"H\" 5 5 1 4 #> 6 min M+ \"M\" 6 6 1 5 #> 7 sec S+ \"S\" 7 7 1 6 # Repeating the same special patterns, e.g. \"yy\" still counts as one pattern # only. sdtm.oak:::parse_dttm_fmt(\"yymmdd HHMMSS\") #> # A tibble: 7 × 7 #> fmt_c pat cap start end len ord #> #> 1 year y+ \"yy\" 1 2 2 1 #> 2 mon m+ \"mm\" 3 4 2 2 #> 3 mday d+ \"dd\" 5 6 2 3 #> 4 NA NA \" \" 7 7 1 NA #> 5 hour H+ \"HH\" 8 9 2 4 #> 6 min M+ \"MM\" 10 11 2 5 #> 7 sec S+ \"SS\" 12 13 2 6 # Note that `\"y\"`, `\"m\"`, `\"d\"`, `\"H\"`, `\"M\"` or `\"S\"` are reserved patterns # that are matched first and interpreted as format components. # Example: the # first \"y\" in \"year\" is parsed as meaning year followed by \"ear y\". The # second \"y\" is not longer matched because a first match already # succeded. sdtm.oak:::parse_dttm_fmt(\"year y\") #> # A tibble: 2 × 7 #> fmt_c pat cap start end len ord #> #> 1 year y+ y 1 1 1 1 #> 2 NA NA ear y 2 6 5 NA # Specify custom patterns sdtm.oak:::parse_dttm_fmt( \"year month day\", fmt_cmp(year = \"year\", mon = \"month\", mday = \"day\") ) #> # A tibble: 5 × 7 #> fmt_c pat cap start end len ord #> #> 1 year year \"year\" 1 4 4 1 #> 2 NA NA \" \" 5 5 1 NA #> 3 mon month \"month\" 6 10 5 2 #> 4 NA NA \" \" 11 11 1 NA #> 5 mday day \"day\" 12 14 3 3"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve date/time parsing problems — problems","title":"Retrieve date/time parsing problems — problems","text":"problems() companion helper function create_iso8601(). retrieves ISO 8601 parsing problems object class iso8601, create_iso8601()'s return value might contain problems attribute case parsing failures. problems() helper function provides easy access parsing problems.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve date/time parsing problems — problems","text":"","code":"problems(x = .Last.value)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve date/time parsing problems — problems","text":"x object class iso8601, typically obtained call create_iso8601(). argument can also left empty, case problems() use last returned value, making convenient use immediately create_iso8601().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve date/time parsing problems — problems","text":"parsing problems x, returned value NULL; otherwise, tibble parsing failures returned. row corresponds parsing problem. first column named ..indicating position(s) inputs create_iso8601() call resulted failures; remaining columns correspond original input values passed create_iso8601(), columns automatically named ..var1, ..var2, , inputs create_iso8601() unnamed, otherwise, original variable names used instead.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/problems.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve date/time parsing problems — problems","text":"","code":"dates <- c( \"2020-01-01\", \"2020-02-11\", \"2020-01-06\", \"2020-0921\", \"2020/10/30\", \"2020-12-05\", \"20231225\" ) # By inspecting the problematic dates it can be understood that # the `.format` parameter needs to updated to include other variations. iso8601_dttm <- create_iso8601(dates, .format = \"y-m-d\") problems(iso8601_dttm) #> # A tibble: 3 × 2 #> ..i ..var1 #> #> 1 4 2020-0921 #> 2 5 2020/10/30 #> 3 7 20231225 # Including more parsing formats addresses the previous problems formats <- c(\"y-m-d\", \"y-md\", \"y/m/d\", \"ymd\") iso8601_dttm2 <- create_iso8601(dates, .format = list(formats)) # So now `problems()` returns `NULL` because there are no more parsing issues. problems(iso8601_dttm2) # If you pass named arguments when calling `create_iso8601()` then they will # be used to create the problems object. iso8601_dttm3 <- create_iso8601(date = dates, .format = \"y-m-d\") problems(iso8601_dttm3) #> # A tibble: 3 × 2 #> ..i date #> #> 1 4 2020-0921 #> 2 5 2020/10/30 #> 3 7 20231225"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/pseq.html","id":null,"dir":"Reference","previous_headings":"","what":"Parallel sequence generation — pseq","title":"Parallel sequence generation — pseq","text":"pseq() similar seq() conveniently accepts integer vectors inputs , allowing parallel generation sequences. result union generated sequences.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/pseq.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Parallel sequence generation — pseq","text":"","code":"pseq(from, to)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/pseq.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Parallel sequence generation — pseq","text":"integer vector. starting value(s) sequence(s). integer vector. ending value(s) sequence(s).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/pseq.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Parallel sequence generation — pseq","text":"integer vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":null,"dir":"Reference","previous_headings":"","what":"Read in a controlled terminology — read_ct_spec","title":"Read in a controlled terminology — read_ct_spec","text":"read_ct_spec() imports controlled terminology specification data set tibble.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read in a controlled terminology — read_ct_spec","text":"","code":"read_ct_spec(file = stop(\"`file` must be specified\"))"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read in a controlled terminology — read_ct_spec","text":"file path file containing controlled terminology specification data set. following expected file: file expected CSV file; file expected contain first row column names; minimal set variables expected: codelist_code, collected_value, term_synonyms, term_value.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read in a controlled terminology — read_ct_spec","text":"tibble controlled terminology specification.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read in a controlled terminology — read_ct_spec","text":"","code":"# Get the local path to one of the controlled terminology example files. path <- ct_spec_example(\"ct-01-cm\") # Import it to R. read_ct_spec(file = path) #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist "},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":null,"dir":"Reference","previous_headings":"","what":"Read an example controlled terminology specification — read_ct_spec_example","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"read_ct_spec_example() imports one bundled controlled terminology specification data sets tibble R.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"","code":"read_ct_spec_example(example)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"example file name controlled terminology data set bundled {stdm.oak}, run read_ct_spec_example() available example files.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"tibble controlled terminology specification data set, character vector example file names.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/read_ct_spec_example.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Read an example controlled terminology specification — read_ct_spec_example","text":"","code":"# Leave the `example` parameter as missing for available example files. read_ct_spec_example() #> [1] \"ct-01-cm.csv\" # Read an example controlled terminology spec file. read_ct_spec_example(\"ct-01-cm.csv\") #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist # You may omit the file extension. read_ct_spec_example(\"ct-01-cm\") #> # A tibble: 33 × 8 #> codelist_code term_code CodedData term_value collected_value #> #> 1 C71113 C25473 QD QD QD (Every Day) #> 2 C71113 C64496 BID BID BID (Twice a Day) #> 3 C71113 C64499 PRN PRN PRN (As Needed) #> 4 C71113 C64516 Q2H Q2H Q2H (Every 2 Hours) #> 5 C71113 C64530 QID QID QID (4 Times a Day) #> 6 C66726 C25158 CAPSULE CAPSULE Capsule #> 7 C66726 C25394 PILL PILL Pill #> 8 C66726 C29167 LOTION LOTION Lotion #> 9 C66726 C42887 AEROSOL AEROSOL Aerosol #> 10 C66726 C42944 INHALANT INHALANT Inhalant #> # ℹ 23 more rows #> # ℹ 3 more variables: term_preferred_term , term_synonyms , #> # raw_codelist "},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":null,"dir":"Reference","previous_headings":"","what":"Recode values — recode","title":"Recode values — recode","text":"recode() recodes values x matching elements onto values .","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Recode values — recode","text":"","code":"recode(x, from = unique(na.omit(x)), to = from, .no_match = x, .na = NA)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Recode values — recode","text":"x atomic vector values recoded. vector values matched x recoding. vector values used replacement values . .no_match Value used replacement cases matched. .na Value used recode missing values.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Recode values — recode","text":"vector recoded values.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/recode.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Recode values — recode","text":"","code":"x <- c(\"male\", \"female\", \"x\", NA) sdtm.oak:::recode(x, from = c(\"male\", \"female\"), to = c(\"M\", \"F\") ) #> [1] \"M\" \"F\" \"x\" NA sdtm.oak:::recode( x, from = c(\"male\", \"female\"), to = c(\"M\", \"F\"), .no_match = \"?\" ) #> [1] \"M\" \"F\" \"?\" NA sdtm.oak:::recode( x, from = c(\"male\", \"female\"), to = c(\"M\", \"F\"), .na = \"missing\" ) #> [1] \"M\" \"F\" \"x\" \"missing\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/reg_matches.html","id":null,"dir":"Reference","previous_headings":"","what":"regmatches() with NA — reg_matches","title":"regmatches() with NA — reg_matches","text":"reg_matches() thin wrapper around regmatches() returns NA instead character(0) matching fails.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/reg_matches.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"regmatches() with NA — reg_matches","text":"","code":"reg_matches(x, m, invert = FALSE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/reg_matches.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"regmatches() with NA — reg_matches","text":"x character vector. m object match data. invert logical scalar. TRUE, extract replace non-matched substrings.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/reg_matches.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"regmatches() with NA — reg_matches","text":"list character vectors matched substrings, NA matching failed.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":null,"dir":"Reference","previous_headings":"","what":"Utility function to assemble a regex of alternative patterns — regex_or","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"regex_or() takes set patterns binds (\"|\") pattern easy regex alternative patterns.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"","code":"regex_or(x, .open = FALSE, .close = FALSE)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"x character vector alternative patterns. .open Whether resulting regex start \"|\". .close Whether resulting regex end \"|\".","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"character scalar resulting regex.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/regex_or.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Utility function to assemble a regex of alternative patterns — regex_or","text":"","code":"# A regex for matching either \"jan\" or \"feb\" sdtm.oak:::regex_or(c(\"jan\", \"feb\")) #> [1] \"jan|feb\" # Setting `.open` and/or `.close` to `TRUE` can be handy if this regex # is to be combined into a larger regex. paste0(sdtm.oak:::regex_or(c(\"jan\", \"feb\"), .close = TRUE), r\"{\\d{2}}\") #> [1] \"jan|feb|\\\\d{2}\""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm.oak-package.html","id":null,"dir":"Reference","previous_headings":"","what":"sdtm.oak: SDTM Data Transformation Engine — sdtm.oak-package","title":"sdtm.oak: SDTM Data Transformation Engine — sdtm.oak-package","text":"EDC Data Standard-agnostic SDTM data transformation engine designed SDTM programming R. Powered metadata sdtm.oak can automate conversion raw clinical data SDTM standardized mapping algorithms. SDTM one required standards data submission FDA (U.S.) PMDA (Japan). SDTM standards implemented accordance SDTM Implementation Guide defined CDISC https://www.cdisc.org/standards/foundational/sdtmig.","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm.oak-package.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"sdtm.oak: SDTM Data Transformation Engine — sdtm.oak-package","text":"Maintainer: Rammprasad Ganapathy ganapathy.rammprasad@gene.com Authors: Adam Forys Edgar Manukyan Rosemary Li Preetesh Parikh Lisa Houterloot Yogesh Gupta Omar Garcia ogcalderon@cdisc.org Ramiro Magno rmagno@pattern.institute (ORCID) contributors: Pattern Institute [copyright holder, funder] F. Hoffmann-La Roche AG [copyright holder, funder] Pfizer Inc [copyright holder, funder]","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_assign.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an SDTM variable — sdtm_assign","title":"Derive an SDTM variable — sdtm_assign","text":"sdtm_assign() internal function packing functionality assign_no_ct() assign_ct() together aimed developers . user please use either assign_no_ct() assign_ct().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_assign.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an SDTM variable — sdtm_assign","text":"","code":"sdtm_assign( raw_dat, raw_var, tgt_var, ct_spec = NULL, ct_clst = NULL, tgt_dat = NULL, id_vars = oak_id_vars() )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_assign.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an SDTM variable — sdtm_assign","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable: single string indicating name raw variable raw_dat. tgt_var target SDTM variable: single string indicating name variable derived. ct_spec Study controlled terminology specification: dataframe minimal set columns, see ct_spec_vars() details. parameter optional, left NULL controlled terminology recoding applied. ct_clst codelist code indicating subset controlled terminology apply derivation. parameter optional, left NULL, possible recodings ct_spec attempted. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (raw_dat).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_assign.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an SDTM variable — sdtm_assign","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_hardcode.html","id":null,"dir":"Reference","previous_headings":"","what":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","title":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","text":"sdtm_hardcode() internal function packing functionality hardcode_no_ct() hardcode_ct() together aimed developers . user please use either hardcode_no_ct() hardcode_ct().","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_hardcode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","text":"","code":"sdtm_hardcode( raw_dat, raw_var, tgt_var, tgt_val, ct_spec = NULL, ct_clst = NULL, tgt_dat = NULL, id_vars = oak_id_vars() )"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_hardcode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","text":"raw_dat raw dataset (dataframe); must include variables passed id_vars raw_var. raw_var raw variable: single string indicating name raw variable raw_dat. tgt_var target SDTM variable: single string indicating name variable derived. tgt_val target SDTM value hardcoded variable indicated tgt_var. ct_spec Study controlled terminology specification: dataframe minimal set columns, see ct_spec_vars() details. parameter optional, left NULL controlled terminology recoding applied. ct_clst codelist code indicating subset controlled terminology apply derivation. parameter optional, left NULL, possible recodings ct_spec attempted. tgt_dat Target dataset: data frame merged raw_dat variables indicated id_vars. parameter optional, see section Value output changes depending argument value. id_vars Key variables used join raw dataset (raw_dat) target data set (raw_dat).","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/sdtm_hardcode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Derive an SDTM variable with a hardcoded value — sdtm_hardcode","text":"returned data set depends value tgt_dat: target dataset supplied, meaning tgt_dat defaults NULL, returned data set raw_dat, selected variables indicated id_vars, new extra column: derived variable, indicated tgt_var. target dataset provided, merged raw data set raw_dat variables indicated id_vars, new column: derived variable, indicated tgt_var.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/str_to_anycase.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate case insensitive regexps — str_to_anycase","title":"Generate case insensitive regexps — str_to_anycase","text":"str_to_anycase() takes character vector word strings input, generates regular expressions express match case.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/str_to_anycase.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate case insensitive regexps — str_to_anycase","text":"","code":"str_to_anycase(x)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/str_to_anycase.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Generate case insensitive regexps — str_to_anycase","text":"x character vector strings consisting word characters.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/str_to_anycase.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Generate case insensitive regexps — str_to_anycase","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert two-digit to four-digit years — yy_to_yyyy","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"yy_to_yyyy() converts two-digit years four-digit years.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"","code":"yy_to_yyyy(x, cutoff_2000 = 68L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"x integer vector years. cutoff_2000 integer value. Two-digit years smaller equal cutoff_2000 parsed though starting 20, otherwise parsed though starting 19.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"integer vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/yy_to_yyyy.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert two-digit to four-digit years — yy_to_yyyy","text":"","code":"sdtm.oak:::yy_to_yyyy(0:5) #> [1] 2000 2001 2002 2003 2004 2005 sdtm.oak:::yy_to_yyyy(2000:2005) #> [1] 2000 2001 2002 2003 2004 2005 sdtm.oak:::yy_to_yyyy(90:99) #> [1] 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 sdtm.oak:::yy_to_yyyy(1990:1999) #> [1] 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 # NB: change in behavior after 68 sdtm.oak:::yy_to_yyyy(65:72) #> [1] 2065 2066 2067 2068 1969 1970 1971 1972 sdtm.oak:::yy_to_yyyy(1965:1972) #> [1] 1965 1966 1967 1968 1969 1970 1971 1972"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"zero_pad_whole_number() takes non-negative integer values converts character zero padding. Negative numbers numbers greater width specified number digits n converted NA.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"","code":"zero_pad_whole_number(x, n = 2L)"},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"x integer vector. n Number digits output, including zero padding.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"character vector.","code":""},{"path":"https://pharmaverse.github.io/sdtm.oak/reference/zero_pad_whole_number.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert an integer to a zero-padded character vector — zero_pad_whole_number","text":"","code":"sdtm.oak:::zero_pad_whole_number(c(-1, 0, 1)) #> [1] NA \"00\" \"01\" sdtm.oak:::zero_pad_whole_number(c(-1, 0, 1, 10, 99, 100), n = 2) #> [1] NA \"00\" \"01\" \"10\" \"99\" NA sdtm.oak:::zero_pad_whole_number(c(-1, 0, 1, 10, 99, 100), n = 3) #> [1] NA \"000\" \"001\" \"010\" \"099\" \"100\""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/news/index.html","id":"new-features-0-0-0-9003","dir":"Changelog","previous_headings":"","what":"New Features","title":"sdtm.oak 0.0.0.9003 (development version)","text":"New function: assign_datetime() deriving ISO8601 date-time variable.","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/news/index.html","id":"new-features-0-0-0-9002","dir":"Changelog","previous_headings":"","what":"New Features","title":"sdtm.oak 0.0.0.9002 (development version)","text":"New function: derive_study_day() study day calculation. New functions basic SDTM derivations: assign_no_ct(), assign_ct(), hardcode_no_ct() hardcode_ct(). New functions handling controlled terminologies: read_ct_spec(), read_ct_spec_example(), ct_spec_example() ct_map().","code":""},{"path":[]},{"path":"https://pharmaverse.github.io/sdtm.oak/news/index.html","id":"new-features-0-0-0-9001","dir":"Changelog","previous_headings":"","what":"New Features","title":"sdtm.oak 0.0.0.9001 (development version)","text":"New function create_iso8601() conversion vectors dates, times date-times ISO8601 format.","code":""}]