From ead17a851f1c267f80bd632867b8647ff7fa0d23 Mon Sep 17 00:00:00 2001 From: bs832471 Date: Thu, 15 Jun 2023 01:48:43 +0000 Subject: [PATCH] docs: #84 options verbose section --- vignettes/deepdive.Rmd | 22 ++++++++++++++++++++++ vignettes/xportr.Rmd | 13 ++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/vignettes/deepdive.Rmd b/vignettes/deepdive.Rmd index a382be53..01b54af8 100644 --- a/vignettes/deepdive.Rmd +++ b/vignettes/deepdive.Rmd @@ -139,6 +139,28 @@ options( ) ``` +## Are we being too verbose? + +One final note on `options()`. 4 of the core `{xportr}` functions have the ability to set messaging as `"none", "message", "warn", "stop"`. Setting each of these in all your calls can be a bit repetitive. You can use `options()` to set these at a higher level and avoid this repitition. + +```{r, eval = FALSE} +# Default +options( + xportr.format_verbose = "none", + xportr.label_verbose = "none", + xportr.length_verbose = "none", + xportr.type_verbose = "none", +) + +# Will send Warning Message to Console +options( + xportr.format_verbose = "warn", + xportr.label_verbose = "warn", + xportr.length_verbose = "warn", + xportr.type_verbose = "warn", +) +``` + ## Going meta Each of the core `{xportr}` functions requires several inputs: A valid dataframe, a metadata object and a domain name, along with optional messaging. For example, here is a simple call using all of the functions. As you can see, a lot of information is repeated in each call. diff --git a/vignettes/xportr.Rmd b/vignettes/xportr.Rmd index 5dd083ec..7a29730f 100644 --- a/vignettes/xportr.Rmd +++ b/vignettes/xportr.Rmd @@ -100,7 +100,7 @@ DT::datatable(adsl, options = list( autoWidth = FALSE, scrollX = TRUE, pageLength = 5, lengthMenu = c(5, 10, 15, 20) )) %>% - formatStyle(0, target = "row", color = "black", backgroundColor = "white", fontWeight = "bold", lineHeight = "70%") + formatStyle(0, target = "row", color = "black", backgroundColor = "white", fontWeight = "bold") ``` **NOTE:** The `ADSL` dataset can be created by using this command `admiral::use_ad_template("adsl")`. @@ -128,11 +128,15 @@ DT::datatable(var_spec_view, options = list( autoWidth = FALSE, scrollX = TRUE, pageLength = 5, lengthMenu = c(5, 10, 15, 20) )) %>% - formatStyle(0, target = "row", color = "black", backgroundColor = "white", fontWeight = "bold", lineHeight = "70%") + formatStyle(0, target = "row", color = "black", backgroundColor = "white", fontWeight = "bold") ``` # xportr_type() +**NOTE:** We make use of `str()` to expose the attributes (length, labels, formats, type) +of the datasets. We have suppressed these calls for the sake of brevity. + + In order to be compliant with transport v5 specifications an `xpt` file can only have two data types: character and numeric/dbl. Currently the `ADSL` data set has chr, dbl, time, factor and date. ```{r, max_height = "200px", echo = FALSE} @@ -188,7 +192,7 @@ DT::datatable(adsl_order, options = list( autoWidth = FALSE, scrollX = TRUE, pageLength = 5, lengthMenu = c(5, 10, 15, 20) )) %>% - formatStyle(0, target = "row", color = "black", backgroundColor = "white", fontWeight = "bold", lineHeight = "70%") + formatStyle(0, target = "row", color = "black", backgroundColor = "white", fontWeight = "bold") ``` # xportr_format() @@ -227,6 +231,9 @@ tribble( ) ``` +**NOTE:** You can use `attr(data$variable, which = "format")` to inspect formats applied +to a dataframe. The above output has these individual calls bound together for easier viewing. + # xportr_label() Please observe that our `ADSL` dataset is missing many variable labels. Sometimes these labels can be lost while using R's function. However, a CDISC compliant data set needs to have each variable with a label.