diff --git a/cran-comments.md b/cran-comments.md index dc9a0c23..55ff521f 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,4 +1,6 @@ -## xportr 0.1.0 +## xportr 0.1.0 Submission 2 + +Per comments from Gregor Seyer, the optoins setting in the xportr.Rmd was removed. A grep was also run to check for other instances. Check Results: diff --git a/docs/404.html b/docs/404.html index c4a94e4f..398e0a4f 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1,75 +1,35 @@ - - - - + + + + - Page not found (404) • xportr - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - - - - -
-
- + +
+ + + - - -
+
+
-
+ + - - diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index e3ae0421..771e868f 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -1,75 +1,12 @@ - - - - - - - -License • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -License • xportr + + - - - - -
-
- -
- -
+
+
-
- +
- - + + diff --git a/docs/LICENSE.html b/docs/LICENSE.html index ff65e7de..11098502 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -1,75 +1,12 @@ - - - - - - - -MIT License • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -MIT License • xportr + + - - - - -
-
- -
- -
+
+
-
- +
- - + + diff --git a/docs/articles/index.html b/docs/articles/index.html index 4f759231..352bbcec 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -1,75 +1,12 @@ - - - - - - - -Articles • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Articles • xportr + + - - - - -
-
- -
- -
+
-

Write

+

All vignettes

-
-
-
-
-

Check

-

- -
-
-
-
-

Metacore

-

- -
-
-
+
Getting Started
+
+
-
- +
- - + + diff --git a/docs/articles/xportr.html b/docs/articles/xportr.html index 4a838d95..830db069 100644 --- a/docs/articles/xportr.html +++ b/docs/articles/xportr.html @@ -27,6 +27,8 @@ + +
- - - -
+ + + + +
-
-

-What we will cover

-


-

We will demonstrate the 6 main functions within xportr:

+
+

Getting Started with xportr +

+

The demo will make use of a small ADSL data set that is +apart of the {admiral} +package. The script that generates this ADSL dataset can be +created by using this command +admiral::use_ad_template("adsl").

+

The ADSL has the following features:

    -
  • xportr_type()
  • -
  • xportr_length()
  • -
  • xportr_label()
  • -
  • xportr_df_label()
  • -
  • xportr_varnames()
  • -
  • xportr_write()
  • +
  • 306 observations
  • +
  • 48 variables
  • +
  • Data types other than character and numeric
  • +
  • Missing labels on variables
  • +
  • Missing label for data set
  • +
  • Order of varibles not following specification file
  • +
  • Formats missing
-

The demo will make use of a small adsl data set that is included in this package. Other vignettes within this package make use of the CDISC Pilot Study Data.

-

The adsl has the following features:

+

To create a fully compliant v5 xpt ADSL dataset, that +was developed using R, we will need to apply the 6 main functions within +the xportr package:

-


-library(haven)
-library(dplyr)
-library(labelled)
-library(xportr)
-
+# Loading packages
+library(dplyr)
+library(labelled)
+library(xportr)
+library(admiral)
 
-adsl <- haven::read_sas( system.file("extdata", "adsl.sas7bdat", package="xportr"))
+# Loading in our example data +adsl <- admiral::admiral_adsl


-
-


+
+


+

NOTE: Dataset can be created by using this command +admiral::use_ad_template("adsl").

-
-

-Preparing your Specification Files

+
+

Preparing your Specification Files +


-

In order to make use of the functions within xportr you will need to create two R data frame objects that contain your data set specifications. For our examples, we have referenced specifications files contained in the package. Here we have called those two objects var_spec and data_spec. Please note, the change of variable names for each. You will most likely need to do some pre-processing of your spec sheets after loading in the spec files for them to work appropriately with the xportr functions.

+

In order to make use of the functions within xportr you +will need to create an R data frame that contains your specification +file. You will most likely need to do some pre-processing of your spec +sheets after loading in the spec files for them to work appropriately +with the xportr functions. Please see our example spec +sheets in +system.file(paste0("specs/", "ADaM_admiral_spec.xlsx"), package = "xportr") +to see how xportr expects the specification sheets.


-var_spec <- readxl::read_xlsx(
-  system.file("specs", "ADaM_spec.xlsx", package="xportr"), sheet = "Variables") %>%
-  dplyr::rename(type = "Data Type") %>%
-  rlang::set_names(tolower) 
-  
-data_spec <- readxl::read_xlsx(
-  system.file("specs", "ADaM_spec.xlsx", package="xportr"), sheet = "Datasets") %>%
-  rlang::set_names(tolower) %>%
-  dplyr::rename(label = "description")
+var_spec <- readxl::read_xlsx( + system.file(paste0("specs/", "ADaM_admiral_spec.xlsx"), package = "xportr"), sheet = "Variables") %>% + dplyr::rename(type = "Data Type") %>% + rlang::set_names(tolower) +


-

The spec file within this package contains 34 of the most CDISC ADaM data sets. Below is a quick snapshot of the specification file pertaining to the adsl data set, which we will make use of in the 5 xportr functions below.

+

Below is a quick snapshot of the specification file pertaining to the +ADSL data set, which we will make use of in the 6 +xportr function calls below. Take note of the order, label, +type, length and format columns.


-
-


+
+


-
-

-xportr_type

+
+

xportr_type() +


-

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 and date.

+

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.

look_for(adsl, details = TRUE)
-   pos variable label col_type values                              
-   1   STUDYID  —     chr      range: mid987650 - mid987650        
-   2   SITEID   —     dbl      range: 214356 - 214356              
-   3   USUBJID  —     chr      range: 987650.000001 - 987650.000024
-   4   SUBJID   —     dbl      range: 1 - 24                       
-   5   COUNTRY  —     chr      range: USA - USA                    
-   6   ACOUNTRY —     chr      range: UNITED STATES - UNITED STATES
-   7   AGE      —     dbl      range: 27 - 62                      
-   8   AGEU     —     chr      range: YEARS - YEARS                
-   9   SEX      —     chr      range: F - M                        
-   10  RACE     —     chr      range: ASIAN - WHITE                
-   11  RACEN    —     dbl      range: 1 - 2                        
-   12  WEIGHTBL —     dbl      range: 56 - 88                      
-   13  TRT01A   —     chr      range: Active - Placebo             
-   14  TRT01AN  —     dbl      range: 1 - 2                        
-   15  SAFFL    —     chr      range: Y - Y                        
-   16  SCRDT    —     date     range: 2018-04-08 - 2018-04-18      
-   17  RANDDT   —     date     range: 2018-04-08 - 2018-04-18      
-   18  TRTSDT   —     date     range: 2018-04-08 - 2018-04-18      
-   19  TRTSTM   —     time     range: 38820 - 74700                
-   20  TRTEDT   —     date     range: 2018-04-16 - 2018-05-01      
-   21  TRTETM   —     time     range: 33240 - 54000                
-   22  BRTHDT   —     date     range: 1956-06-30 - 1991-06-30      
-   23  BRTHDTC  —     dbl      range: 1956 - 1991
+ pos variable label col_type values + 1 STUDYID Study Identifier chr range: CDISCPILOT01 - CDI~ + 2 USUBJID Unique Subject Identifier chr range: 01-701-1015 - 01-7~ + 3 SUBJID Subject Identifier for th~ chr range: 1001 - 1448 + 4 RFSTDTC Subject Reference Start D~ chr range: 2012-07-09 - 2014-~ + 5 RFENDTC Subject Reference End Dat~ chr range: 2012-09-01 - 2015-~ + 6 RFXSTDTC Date/Time of First Study ~ chr range: 2012-07-09 - 2014-~ + 7 RFXENDTC Date/Time of Last Study T~ chr range: 2012-08-28 - 2015-~ + 8 RFICDTC Date/Time of Informed Con~ chr range: + 9 RFPENDTC Date/Time of End of Parti~ chr range: 2012-08-13 - 2015-~ + 10 DTHDTC Date/Time of Death chr range: 2013-01-14 - 2014-~ + 11 DTHFL Subject Death Flag chr range: Y - Y + 12 SITEID Study Site Identifier chr range: 701 - 718 + 13 AGE Age dbl range: 50 - 89 + 14 AGEU Age Units chr range: YEARS - YEARS + 15 SEX Sex chr range: F - M + 16 RACE Race chr range: AMERICAN INDIAN OR~ + 17 ETHNIC Ethnicity chr range: HISPANIC OR LATINO~ + 18 ARMCD Planned Arm Code chr range: Pbo - Xan_Lo + 19 ARM Description of Planned Arm chr range: Placebo - Xanomeli~ + 20 ACTARMCD Actual Arm Code chr range: Pbo - Xan_Lo + 21 ACTARM Description of Actual Arm chr range: Placebo - Xanomeli~ + 22 COUNTRY Country chr range: USA - USA + 23 DMDTC Date/Time of Collection chr range: 2012-07-06 - 2014-~ + 24 DMDY Study Day of Collection dbl range: -37 - -2 + 25 TRT01P Description of Planned Arm chr range: Placebo - Xanomeli~ + 26 TRT01A Description of Actual Arm chr range: Placebo - Xanomeli~ + 27 TRTSDTM — dttm range: 2012-07-09 - 2014-~ + 28 TRTEDTM — dttm range: 2012-08-28 23:59:5~ + 29 TRTSDT — date range: 2012-07-09 - 2014-~ + 30 TRTEDT — date range: 2012-08-28 - 2015-~ + 31 TRTDURD — dbl range: 1 - 212 + 32 SCRFDT — date range: 2012-08-13 - 2014-~ + 33 EOSDT — date range: 2012-09-01 - 2015-~ + 34 EOSSTT — chr range: COMPLETED - DISCON~ + 35 FRVDT — date range: 2013-02-18 - 2014-~ + 36 DTHDT — date range: 2013-01-14 - 2014-~ + 37 DTHDTF — chr range: + 38 DTHADY — dbl range: 12 - 175 + 39 LDDTHELD — dbl range: 0 - 2 + 40 LSTALVDT — date range: 2012-09-01 - 2015-~ + 41 AGEGR1 — fct <18 + 18-64 + >=65 + 42 SAFFL — chr range: Y - Y + 43 RACEGR1 — chr range: Non-white - White + 44 REGION1 — chr range: NA - NA + 45 LDDTHGR1 — chr range: <= 30 - <= 30 + 46 DTH30FL — chr range: Y - Y + 47 DTHA30FL — chr range: + 48 DTHB30FL — chr range: Y - Y


-

Using xport_type and the supplied specification file, we can coerce the variables in the adsl set to be either numeric or character. A message is given if variables were not coerced, this is due to the variables not being in the specification file.

+

Using xport_type and the supplied specification file, we +can coerce the variables in the ADSL set to be +either numeric or character.


-
# .df <- adsl %>% mutate(`1BIGLong_Var` = "test")
-adsl_type <- xportr_type(.df = adsl, metacore =  var_spec, domain = "ADSL", verbose = "message") 
-  Variable type(s) in `.df` don't match metadata: `STUDYID`, `SITEID`, `USUBJID`, `SUBJID`, `COUNTRY`, `AGE`, `AGEU`, `SEX`, `RACE`, `WEIGHTBL`, `TRT01A`, `TRT01AN`, `SAFFL`, `RANDDT`, `TRTSDT`, and `TRTEDT`
-  
-  ── Variable type mismatches found. ──
-  
-  ✓ 16 variables coerced
-


-
   pos variable label col_type values                              
-   1   STUDYID  —     chr      range: mid987650 - mid987650        
-   2   SITEID   —     chr      range: 214356 - 214356              
-   3   USUBJID  —     chr      range: 987650.000001 - 987650.000024
-   4   SUBJID   —     chr      range: 1 - 9                        
-   5   COUNTRY  —     chr      range: USA - USA                    
-   6   ACOUNTRY —     chr      range: UNITED STATES - UNITED STATES
-   7   AGE      —     dbl      range: 27 - 62                      
-   8   AGEU     —     chr      range: YEARS - YEARS                
-   9   SEX      —     chr      range: F - M                        
-   10  RACE     —     chr      range: ASIAN - WHITE                
-   11  RACEN    —     dbl      range: 1 - 2                        
-   12  WEIGHTBL —     dbl      range: 56 - 88                      
-   13  TRT01A   —     chr      range: Active - Placebo             
-   14  TRT01AN  —     dbl      range: 1 - 2                        
-   15  SAFFL    —     chr      range: Y - Y                        
-   16  SCRDT    —     dbl      range: 17629 - 17639                
-   17  RANDDT   —     dbl      range: 17629 - 17639                
-   18  TRTSDT   —     dbl      range: 17629 - 17639                
-   19  TRTSTM   —     dbl      range: 38820 - 74700                
-   20  TRTEDT   —     dbl      range: 17637 - 17652                
-   21  TRTETM   —     dbl      range: 33240 - 54000                
-   22  BRTHDT   —     dbl      range: -4933 - 7850                 
-   23  BRTHDTC  —     dbl      range: 1956 - 1991
+
+adsl_type <- xportr_type(adsl, var_spec, domain = "ADSL", verbose = "message") 
+


Now all appropriate types have been applied to the dataset as +seen below.

+
look_for(adsl_type, details = TRUE)
+   pos variable label col_type values                                          
+   1   STUDYID  —     chr      range: CDISCPILOT01 - CDISCPILOT01              
+   2   USUBJID  —     chr      range: 01-701-1015 - 01-718-1427                
+   3   SUBJID   —     chr      range: 1001 - 1448                              
+   4   RFSTDTC  —     chr      range: 2012-07-09 - 2014-09-02                  
+   5   RFENDTC  —     chr      range: 2012-09-01 - 2015-03-05                  
+   6   RFXSTDTC —     chr      range: 2012-07-09 - 2014-09-02                  
+   7   RFXENDTC —     chr      range: 2012-08-28 - 2015-03-05                  
+   8   RFICDTC  —     chr      range:                                          
+   9   RFPENDTC —     chr      range: 2012-08-13 - 2015-03-05T14:40            
+   10  DTHDTC   —     chr      range: 2013-01-14 - 2014-11-01                  
+   11  DTHFL    —     chr      range: Y - Y                                    
+   12  SITEID   —     chr      range: 701 - 718                                
+   13  AGE      —     dbl      range: 50 - 89                                  
+   14  AGEU     —     chr      range: YEARS - YEARS                            
+   15  SEX      —     chr      range: F - M                                    
+   16  RACE     —     chr      range: AMERICAN INDIAN OR ALASKA NATIVE - WHITE 
+   17  ETHNIC   —     chr      range: HISPANIC OR LATINO - NOT HISPANIC OR LAT~
+   18  ARMCD    —     chr      range: Pbo - Xan_Lo                             
+   19  ARM      —     chr      range: Placebo - Xanomeline Low Dose            
+   20  ACTARMCD —     chr      range: Pbo - Xan_Lo                             
+   21  ACTARM   —     chr      range: Placebo - Xanomeline Low Dose            
+   22  COUNTRY  —     chr      range: USA - USA                                
+   23  DMDTC    —     chr      range: 2012-07-06 - 2014-08-29                  
+   24  DMDY     —     dbl      range: -37 - -2                                 
+   25  TRT01P   —     chr      range: Placebo - Xanomeline Low Dose            
+   26  TRT01A   —     chr      range: Placebo - Xanomeline Low Dose            
+   27  TRTSDTM  —     dbl      range: 1341792000 - 1409616000                  
+   28  TRTEDTM  —     dbl      range: 1346198399 - 1425599999                  
+   29  TRTSDT   —     dbl      range: 15530 - 16315                            
+   30  TRTEDT   —     dbl      range: 15580 - 16499                            
+   31  TRTDURD  —     dbl      range: 1 - 212                                  
+   32  SCRFDT   —     dbl      range: 15565 - 16181                            
+   33  EOSDT    —     dbl      range: 15584 - 16499                            
+   34  EOSSTT   —     chr      range: COMPLETED - DISCONTINUED                 
+   35  FRVDT    —     dbl      range: 15754 - 16389                            
+   36  DTHDT    —     dbl      range: 15719 - 16375                            
+   37  DTHDTF   —     chr      range:                                          
+   38  DTHADY   —     dbl      range: 12 - 175                                 
+   39  LDDTHELD —     dbl      range: 0 - 2                                    
+   40  LSTALVDT —     dbl      range: 15584 - 16499                            
+   41  AGEGR1   —     chr      range: >=65 - 18-64                             
+   42  SAFFL    —     chr      range: Y - Y                                    
+   43  RACEGR1  —     chr      range: Non-white - White                        
+   44  REGION1  —     chr      range: NA - NA                                  
+   45  LDDTHGR1 —     chr      range: <= 30 - <= 30                            
+   46  DTH30FL  —     chr      range: Y - Y                                    
+   47  DTHA30FL —     chr      range:                                          
+   48  DTHB30FL —     chr      range: Y - Y
-
-

-xportr_length

-


-

Next we can apply the lengths from a variable level specification file to the data frame. xportr_length will identify variables that are missing from your specification file. The function will also alert you to how many lengths have been applied successfully. Before we apply the lengths lets verify that no lengths have been applied to the original dataframe.

-


-
capture.output(str(adsl, give.head=TRUE)) %>% 
-  as_tibble() %>% 
-  head(n=7)
-  # A tibble: 7 × 1
-    value                                                                         
-    <chr>                                                                         
-  1 "tibble [24 × 23] (S3: tbl_df/tbl/data.frame)"                                
-  2 " $ STUDYID : chr [1:24] \"mid987650\" \"mid987650\" \"mid987650\" \"mid98765…
-  3 "  ..- attr(*, \"format.sas\")= chr \"$\""                                    
-  4 " $ SITEID  : num [1:24] 214356 214356 214356 214356 214356 ..."              
-  5 "  ..- attr(*, \"format.sas\")= chr \"BEST\""                                 
-  6 " $ USUBJID : chr [1:24] \"987650.000001\" \"987650.000002\" \"987650.000003\…
-  7 "  ..- attr(*, \"format.sas\")= chr \"$\""
+
+

xportr_length() +


-

No lengths have been applied to the variables as seen in the printout for the first 3 variables. Let’s now use xportr_length to apply our lengths from the specification file.

+

Next we can apply the lengths from a variable level specification +file to the data frame. xportr_length will identify +variables that are missing from your specification file. The function +will also alert you to how many lengths have been applied successfully. +Before we apply the lengths lets verify that no lengths have been +applied to the original dataframe.


-
adsl_length <- adsl %>% xportr_length(var_spec, "ADSL", "message")
-  
-  ── Variable lengths missing from metadata. ──
-  
-7 lengths resolved
-  Variable(s) present in `.df` but doesn't exist in `metacore`.
-  x Problem with `ACOUNTRY`, `RACEN`, `SCRDT`, `TRTSTM`, `TRTETM`, `BRTHDT`, and `BRTHDTC`
+
+str(adsl)
+
  tibble [306 × 48] (S3: tbl_df/tbl/data.frame)
+   $ STUDYID : chr [1:306] "CDISCPILOT01" "CDISCPILOT01" "CDISCPILOT01" "CDISCPILOT01" ...
+    ..- attr(*, "label")= chr "Study Identifier"
+   $ USUBJID : chr [1:306] "01-701-1015" "01-701-1023" "01-701-1028" "01-701-1033" ...
+    ..- attr(*, "label")= chr "Unique Subject Identifier"
+   $ SUBJID  : chr [1:306] "1015" "1023" "1028" "1033" ...
+    ..- attr(*, "label")= chr "Subject Identifier for the Study"
+   $ RFSTDTC : chr [1:306] "2014-01-02" "2012-08-05" "2013-07-19" "2014-03-18" ...
+    ..- attr(*, "label")= chr "Subject Reference Start Date/Time"
+   $ RFENDTC : chr [1:306] "2014-07-02" "2012-09-02" "2014-01-14" "2014-04-14" ...
+    ..- attr(*, "label")= chr "Subject Reference End Date/Time"
+   $ RFXSTDTC: chr [1:306] "2014-01-02" "2012-08-05" "2013-07-19" "2014-03-18" ...
+    ..- attr(*, "label")= chr "Date/Time of First Study Treatment"
+   $ RFXENDTC: chr [1:306] "2014-07-02" "2012-09-01" "2014-01-14" "2014-03-31" ...
+    ..- attr(*, "label")= chr "Date/Time of Last Study Treatment"
+   $ RFICDTC : chr [1:306] NA NA NA NA ...
+    ..- attr(*, "label")= chr "Date/Time of Informed Consent"
+   $ RFPENDTC: chr [1:306] "2014-07-02T11:45" "2013-02-18" "2014-01-14T11:10" "2014-09-15" ...
+    ..- attr(*, "label")= chr "Date/Time of End of Participation"
+   $ DTHDTC  : chr [1:306] NA NA NA NA ...
+    ..- attr(*, "label")= chr "Date/Time of Death"
+   $ DTHFL   : chr [1:306] NA NA NA NA ...
+    ..- attr(*, "label")= chr "Subject Death Flag"
+   $ SITEID  : chr [1:306] "701" "701" "701" "701" ...
+    ..- attr(*, "label")= chr "Study Site Identifier"
+   $ AGE     : num [1:306] 63 64 71 74 77 85 59 68 81 84 ...
+    ..- attr(*, "label")= chr "Age"
+   $ AGEU    : chr [1:306] "YEARS" "YEARS" "YEARS" "YEARS" ...
+    ..- attr(*, "label")= chr "Age Units"
+   $ SEX     : chr [1:306] "F" "M" "M" "M" ...
+    ..- attr(*, "label")= chr "Sex"
+   $ RACE    : chr [1:306] "WHITE" "WHITE" "WHITE" "WHITE" ...
+    ..- attr(*, "label")= chr "Race"
+   $ ETHNIC  : chr [1:306] "HISPANIC OR LATINO" "HISPANIC OR LATINO" "NOT HISPANIC OR LATINO" "NOT HISPANIC OR LATINO" ...
+    ..- attr(*, "label")= chr "Ethnicity"
+   $ ARMCD   : chr [1:306] "Pbo" "Pbo" "Xan_Hi" "Xan_Lo" ...
+    ..- attr(*, "label")= chr "Planned Arm Code"
+   $ ARM     : chr [1:306] "Placebo" "Placebo" "Xanomeline High Dose" "Xanomeline Low Dose" ...
+    ..- attr(*, "label")= chr "Description of Planned Arm"
+   $ ACTARMCD: chr [1:306] "Pbo" "Pbo" "Xan_Hi" "Xan_Lo" ...
+    ..- attr(*, "label")= chr "Actual Arm Code"
+   $ ACTARM  : chr [1:306] "Placebo" "Placebo" "Xanomeline High Dose" "Xanomeline Low Dose" ...
+    ..- attr(*, "label")= chr "Description of Actual Arm"
+   $ COUNTRY : chr [1:306] "USA" "USA" "USA" "USA" ...
+    ..- attr(*, "label")= chr "Country"
+   $ DMDTC   : chr [1:306] "2013-12-26" "2012-07-22" "2013-07-11" "2014-03-10" ...
+    ..- attr(*, "label")= chr "Date/Time of Collection"
+   $ DMDY    : num [1:306] -7 -14 -8 -8 -7 -21 NA -9 -13 -7 ...
+    ..- attr(*, "label")= chr "Study Day of Collection"
+   $ TRT01P  : chr [1:306] "Placebo" "Placebo" "Xanomeline High Dose" "Xanomeline Low Dose" ...
+    ..- attr(*, "label")= chr "Description of Planned Arm"
+   $ TRT01A  : chr [1:306] "Placebo" "Placebo" "Xanomeline High Dose" "Xanomeline Low Dose" ...
+    ..- attr(*, "label")= chr "Description of Actual Arm"
+   $ TRTSDTM : iso_dtm[1:306], format: "2014-01-02" "2012-08-05" ...
+   $ TRTEDTM : iso_dtm[1:306], format: "2014-07-02 23:59:59" "2012-09-01 23:59:59" ...
+   $ TRTSDT  : Date[1:306], format: "2014-01-02" "2012-08-05" ...
+   $ TRTEDT  : Date[1:306], format: "2014-07-02" "2012-09-01" ...
+   $ TRTDURD : num [1:306] 182 28 180 14 183 26 NA 190 10 55 ...
+   $ SCRFDT  : Date[1:306], format: NA NA ...
+   $ EOSDT   : Date[1:306], format: "2014-07-02" "2012-09-02" ...
+   $ EOSSTT  : chr [1:306] "COMPLETED" "DISCONTINUED" "COMPLETED" "DISCONTINUED" ...
+   $ FRVDT   : Date[1:306], format: NA "2013-02-18" ...
+   $ DTHDT   : Date[1:306], format: NA NA ...
+   $ DTHDTF  : chr [1:306] NA NA NA NA ...
+   $ DTHADY  : num [1:306] NA NA NA NA NA NA NA NA NA NA ...
+   $ LDDTHELD: num [1:306] NA NA NA NA NA NA NA NA NA NA ...
+   $ LSTALVDT: Date[1:306], format: "2014-07-02" "2012-09-02" ...
+   $ AGEGR1  : Factor w/ 3 levels "<18","18-64",..: 2 2 3 3 3 3 2 3 3 3 ...
+   $ SAFFL   : chr [1:306] "Y" "Y" "Y" "Y" ...
+   $ RACEGR1 : chr [1:306] "White" "White" "White" "White" ...
+   $ REGION1 : chr [1:306] "NA" "NA" "NA" "NA" ...
+   $ LDDTHGR1: chr [1:306] NA NA NA NA ...
+   $ DTH30FL : chr [1:306] NA NA NA NA ...
+   $ DTHA30FL: chr [1:306] NA NA NA NA ...
+   $ DTHB30FL: chr [1:306] NA NA NA NA ...


-
capture.output(str(adsl_length, give.head=TRUE)) %>% 
-  as_tibble() %>% 
-  head(n=7)
-  # A tibble: 7 × 1
-    value                                                                         
-    <chr>                                                                         
-  1 "tibble [24 × 23] (S3: tbl_df/tbl/data.frame)"                                
-  2 " $ STUDYID : chr [1:24] \"mid987650\" \"mid987650\" \"mid987650\" \"mid98765…
-  3 "  ..- attr(*, \"format.sas\")= chr \"$\""                                    
-  4 "  ..- attr(*, \"SASlength\")= num 21"                                        
-  5 " $ SITEID  : num [1:24] 214356 214356 214356 214356 214356 ..."              
-  6 "  ..- attr(*, \"format.sas\")= chr \"BEST\""                                 
-  7 "  ..- attr(*, \"SASlength\")= num 5"
+

No lengths have been applied to the variables as seen in the printout +- the lengths would be in the attr part of each variables. +Let’s now use xportr_length to apply our lengths from the +specification file.

+
+adsl_length <- adsl %>% xportr_length(var_spec, domain = "ADSL", "message")


-

Lengths have been successfully applied as viewed for the first 3 variables.

+
+str(adsl_length)
+
  tibble [306 × 48] (S3: tbl_df/tbl/data.frame)
+   $ STUDYID : chr [1:306] "CDISCPILOT01" "CDISCPILOT01" "CDISCPILOT01" "CDISCPILOT01" ...
+    ..- attr(*, "label")= chr "Study Identifier"
+    ..- attr(*, "width")= num 21
+   $ USUBJID : chr [1:306] "01-701-1015" "01-701-1023" "01-701-1028" "01-701-1033" ...
+    ..- attr(*, "label")= chr "Unique Subject Identifier"
+    ..- attr(*, "width")= num 30
+   $ SUBJID  : chr [1:306] "1015" "1023" "1028" "1033" ...
+    ..- attr(*, "label")= chr "Subject Identifier for the Study"
+    ..- attr(*, "width")= num 8
+   $ RFSTDTC : chr [1:306] "2014-01-02" "2012-08-05" "2013-07-19" "2014-03-18" ...
+    ..- attr(*, "label")= chr "Subject Reference Start Date/Time"
+    ..- attr(*, "width")= num 19
+   $ RFENDTC : chr [1:306] "2014-07-02" "2012-09-02" "2014-01-14" "2014-04-14" ...
+    ..- attr(*, "label")= chr "Subject Reference End Date/Time"
+    ..- attr(*, "width")= num 19
+   $ RFXSTDTC: chr [1:306] "2014-01-02" "2012-08-05" "2013-07-19" "2014-03-18" ...
+    ..- attr(*, "label")= chr "Date/Time of First Study Treatment"
+    ..- attr(*, "width")= num 19
+   $ RFXENDTC: chr [1:306] "2014-07-02" "2012-09-01" "2014-01-14" "2014-03-31" ...
+    ..- attr(*, "label")= chr "Date/Time of Last Study Treatment"
+    ..- attr(*, "width")= num 19
+   $ RFICDTC : chr [1:306] NA NA NA NA ...
+    ..- attr(*, "label")= chr "Date/Time of Informed Consent"
+    ..- attr(*, "width")= num 19
+   $ RFPENDTC: chr [1:306] "2014-07-02T11:45" "2013-02-18" "2014-01-14T11:10" "2014-09-15" ...
+    ..- attr(*, "label")= chr "Date/Time of End of Participation"
+    ..- attr(*, "width")= num 19
+   $ DTHDTC  : chr [1:306] NA NA NA NA ...
+    ..- attr(*, "label")= chr "Date/Time of Death"
+    ..- attr(*, "width")= num 19
+   $ DTHFL   : chr [1:306] NA NA NA NA ...
+    ..- attr(*, "label")= chr "Subject Death Flag"
+    ..- attr(*, "width")= num 2
+   $ SITEID  : chr [1:306] "701" "701" "701" "701" ...
+    ..- attr(*, "label")= chr "Study Site Identifier"
+    ..- attr(*, "width")= num 5
+   $ AGE     : num [1:306] 63 64 71 74 77 85 59 68 81 84 ...
+    ..- attr(*, "label")= chr "Age"
+    ..- attr(*, "width")= num 8
+   $ AGEU    : chr [1:306] "YEARS" "YEARS" "YEARS" "YEARS" ...
+    ..- attr(*, "label")= chr "Age Units"
+    ..- attr(*, "width")= num 10
+   $ SEX     : chr [1:306] "F" "M" "M" "M" ...
+    ..- attr(*, "label")= chr "Sex"
+    ..- attr(*, "width")= num 1
+   $ RACE    : chr [1:306] "WHITE" "WHITE" "WHITE" "WHITE" ...
+    ..- attr(*, "label")= chr "Race"
+    ..- attr(*, "width")= num 60
+   $ ETHNIC  : chr [1:306] "HISPANIC OR LATINO" "HISPANIC OR LATINO" "NOT HISPANIC OR LATINO" "NOT HISPANIC OR LATINO" ...
+    ..- attr(*, "label")= chr "Ethnicity"
+    ..- attr(*, "width")= num 100
+   $ ARMCD   : chr [1:306] "Pbo" "Pbo" "Xan_Hi" "Xan_Lo" ...
+    ..- attr(*, "label")= chr "Planned Arm Code"
+    ..- attr(*, "width")= num 20
+   $ ARM     : chr [1:306] "Placebo" "Placebo" "Xanomeline High Dose" "Xanomeline Low Dose" ...
+    ..- attr(*, "label")= chr "Description of Planned Arm"
+    ..- attr(*, "width")= num 200
+   $ ACTARMCD: chr [1:306] "Pbo" "Pbo" "Xan_Hi" "Xan_Lo" ...
+    ..- attr(*, "label")= chr "Actual Arm Code"
+    ..- attr(*, "width")= num 20
+   $ ACTARM  : chr [1:306] "Placebo" "Placebo" "Xanomeline High Dose" "Xanomeline Low Dose" ...
+    ..- attr(*, "label")= chr "Description of Actual Arm"
+    ..- attr(*, "width")= num 200
+   $ COUNTRY : chr [1:306] "USA" "USA" "USA" "USA" ...
+    ..- attr(*, "label")= chr "Country"
+    ..- attr(*, "width")= num 3
+   $ DMDTC   : chr [1:306] "2013-12-26" "2012-07-22" "2013-07-11" "2014-03-10" ...
+    ..- attr(*, "label")= chr "Date/Time of Collection"
+    ..- attr(*, "width")= num 19
+   $ DMDY    : num [1:306] -7 -14 -8 -8 -7 -21 NA -9 -13 -7 ...
+    ..- attr(*, "label")= chr "Study Day of Collection"
+    ..- attr(*, "width")= num 8
+   $ TRT01P  : chr [1:306] "Placebo" "Placebo" "Xanomeline High Dose" "Xanomeline Low Dose" ...
+    ..- attr(*, "label")= chr "Description of Planned Arm"
+    ..- attr(*, "width")= num 40
+   $ TRT01A  : chr [1:306] "Placebo" "Placebo" "Xanomeline High Dose" "Xanomeline Low Dose" ...
+    ..- attr(*, "label")= chr "Description of Actual Arm"
+    ..- attr(*, "width")= num 40
+   $ TRTSDTM : iso_dtm[1:306], format: "2014-01-02" "2012-08-05" ...
+   $ TRTEDTM : iso_dtm[1:306], format: "2014-07-02 23:59:59" "2012-09-01 23:59:59" ...
+   $ TRTSDT  : Date[1:306], format: "2014-01-02" "2012-08-05" ...
+   $ TRTEDT  : Date[1:306], format: "2014-07-02" "2012-09-01" ...
+   $ TRTDURD : num [1:306] 182 28 180 14 183 26 NA 190 10 55 ...
+    ..- attr(*, "width")= num 8
+   $ SCRFDT  : Date[1:306], format: NA NA ...
+   $ EOSDT   : Date[1:306], format: "2014-07-02" "2012-09-02" ...
+   $ EOSSTT  : chr [1:306] "COMPLETED" "DISCONTINUED" "COMPLETED" "DISCONTINUED" ...
+    ..- attr(*, "width")= num 200
+   $ FRVDT   : Date[1:306], format: NA "2013-02-18" ...
+   $ DTHDT   : Date[1:306], format: NA NA ...
+   $ DTHDTF  : chr [1:306] NA NA NA NA ...
+    ..- attr(*, "width")= num 2
+   $ DTHADY  : num [1:306] NA NA NA NA NA NA NA NA NA NA ...
+    ..- attr(*, "width")= num 8
+   $ LDDTHELD: num [1:306] NA NA NA NA NA NA NA NA NA NA ...
+    ..- attr(*, "width")= num 8
+   $ LSTALVDT: Date[1:306], format: "2014-07-02" "2012-09-02" ...
+   $ AGEGR1  : Factor w/ 3 levels "<18","18-64",..: 2 2 3 3 3 3 2 3 3 3 ...
+    ..- attr(*, "width")= num 20
+   $ SAFFL   : chr [1:306] "Y" "Y" "Y" "Y" ...
+    ..- attr(*, "width")= num 2
+   $ RACEGR1 : chr [1:306] "White" "White" "White" "White" ...
+    ..- attr(*, "width")= num 200
+   $ REGION1 : chr [1:306] "NA" "NA" "NA" "NA" ...
+    ..- attr(*, "width")= num 80
+   $ LDDTHGR1: chr [1:306] NA NA NA NA ...
+    ..- attr(*, "width")= num 200
+   $ DTH30FL : chr [1:306] NA NA NA NA ...
+    ..- attr(*, "width")= num 200
+   $ DTHA30FL: chr [1:306] NA NA NA NA ...
+    ..- attr(*, "width")= num 200
+   $ DTHB30FL: chr [1:306] NA NA NA NA ...
+    ..- attr(*, "width")= num 200
+   - attr(*, "_xportr.df_arg_")= chr "ADSL"
+

Note the additional attr(*, "width")= after each +variable with the width. These have been directly applied from the +specification file that we loaded above!

-
-

-xportr_label

-


-

Please observe that our adsl data does not have any labels associated with it. A CDISC compliant data set needs to have each variable with a variable label.

-
look_for(adsl, details = FALSE)
-   pos variable label
-    1  STUDYID  —    
-    2  SITEID   —    
-    3  USUBJID  —    
-    4  SUBJID   —    
-    5  COUNTRY  —    
-    6  ACOUNTRY —    
-    7  AGE      —    
-    8  AGEU     —    
-    9  SEX      —    
-   10  RACE     —    
-   11  RACEN    —    
-   12  WEIGHTBL —    
-   13  TRT01A   —    
-   14  TRT01AN  —    
-   15  SAFFL    —    
-   16  SCRDT    —    
-   17  RANDDT   —    
-   18  TRTSDT   —    
-   19  TRTSTM   —    
-   20  TRTEDT   —    
-   21  TRTETM   —    
-   22  BRTHDT   —    
-   23  BRTHDTC  —
-


-

Using the xport_label function we can take the specifications file and label all the variables available. xportr_label will produce a warning message if you the variable in the data set is not in the specification file.

-


-
adsl_update <- adsl %>% xportr_label(var_spec, "ADSL", "message")
-  
-  ── Variable labels missing from metadata. ──
-  
-7 labels skipped
-  Variable(s) present in `.df` but doesn't exist in `metacore`.
-  x Problem with `ACOUNTRY`, `RACEN`, `SCRDT`, `TRTSTM`, `TRTETM`, `BRTHDT`, and `BRTHDTC`
-  Warning: Length of variable label must be 40 characters or less.
-  x Problem with `BMIBLG1N` and `EXACSTDD`.
-
look_for(adsl_update, details = FALSE)
-   pos variable label                              
-    1  STUDYID  Study Identifier                   
-    2  SITEID   Study Site Identifier              
-    3  USUBJID  Unique Subject Identifier          
-    4  SUBJID   Subject Identifier for the Study   
-    5  COUNTRY  Country                            
-    6  ACOUNTRY                                    
-    7  AGE      Age                                
-    8  AGEU     Age Units                          
-    9  SEX      Sex                                
-   10  RACE     Race                               
-   11  RACEN                                       
-   12  WEIGHTBL Baseline Weight                    
-   13  TRT01A   Actual Treatment for Period 01     
-   14  TRT01AN  Actual Treatment for Period 01 (N) 
-   15  SAFFL    Safety Population Flag             
-   16  SCRDT                                       
-   17  RANDDT   Date of Randomization              
-   18  TRTSDT   Date of First Exposure to Treatment
-   19  TRTSTM                                      
-   20  TRTEDT   Date of Last Exposure to Treatment 
-   21  TRTETM                                      
-   22  BRTHDT                                      
-   23  BRTHDTC
+
+

xportr_order() +

+

Please note that the order of the ADSL variables, see +above, does not match specification file order column. We can quickly +remedy this with a call to xportr_order(). Note that the +variable SITEID has been moved as well as many others to +match the specification file order column.

+
+adsl_order <- xportr_order(adsl,var_spec, domain = "ADSL", verbose = "message") 
+
+
-
-

-xportr_df_label

-


-

An appropriate data set label must be supplied as well. Currently, the adsl data set has the label ADSL, but it needs the label Subject-Level Analysis Dataset to be compliant with most clinical data set validator application. Here we make use of the data_spec object to supply the apropriate label for the adsl data set.

-
-

-Option1

-
capture.output(str(adsl))[45]
-  [1] NA
-
adsl_df_lbl <- adsl %>% xportr_df_label(data_spec, "ADSL")
-adsl %>% xportr_varnames("message")
-  
-  Variable Name Validation passed! No renaming necessary.
-  
-  
-  ── 0 of 23 (0%) variables were renamed ──
-  
-  # A tibble: 24 × 23
-     STUDYID  SITEID USUBJID SUBJID COUNTRY ACOUNTRY   AGE AGEU  SEX   RACE  RACEN
-     <chr>     <dbl> <chr>    <dbl> <chr>   <chr>    <dbl> <chr> <chr> <chr> <dbl>
-   1 mid9876… 214356 987650…      1 USA     UNITED …    35 YEARS M     ASIAN     2
-   2 mid9876… 214356 987650…      2 USA     UNITED …    62 YEARS M     WHITE     1
-   3 mid9876… 214356 987650…      3 USA     UNITED …    27 YEARS F     ASIAN     2
-   4 mid9876… 214356 987650…      4 USA     UNITED …    42 YEARS M     ASIAN     2
-   5 mid9876… 214356 987650…      5 USA     UNITED …    59 YEARS F     WHITE     1
-   6 mid9876… 214356 987650…      6 USA     UNITED …    28 YEARS M     WHITE     1
-   7 mid9876… 214356 987650…      7 USA     UNITED …    31 YEARS F     ASIAN     2
-   8 mid9876… 214356 987650…      8 USA     UNITED …    43 YEARS F     WHITE     1
-   9 mid9876… 214356 987650…      9 USA     UNITED …    35 YEARS M     ASIAN     2
-  10 mid9876… 214356 987650…     10 USA     UNITED …    62 YEARS M     WHITE     1
-  # … with 14 more rows, and 12 more variables: WEIGHTBL <dbl>, TRT01A <chr>,
-  #   TRT01AN <dbl>, SAFFL <chr>, SCRDT <date>, RANDDT <date>, TRTSDT <date>,
-  #   TRTSTM <time>, TRTEDT <date>, TRTETM <time>, BRTHDT <date>, BRTHDTC <dbl>
-
-attr(adsl, "label")
+
+

xportr_format() +

+

Now we apply formats to the dataset. These will typically be +DATE9., DATETIME20 or TIME5, but +many others can be used. Notice that 8 Date/Time variables are missing a +format in our ADSL dataset. Here we just take a peak at a +few TRT variables, which have a NULL +format.

+
+attr(adsl$TRTSDT, "format.sas")
+  NULL
+attr(adsl$TRTEDT, "format.sas")
+  NULL
+attr(adsl$TRTSDTM, "format.sas")
+  NULL
+attr(adsl$TRTEDTM, "format.sas")
   NULL
-


-
+

Using our xportr_format() we apply our formats.

+
+adsl_fmt <- adsl %>% xportr_format(var_spec, domain = "ADSL", "message")
+
attr(adsl_fmt$TRTSDT, "format.sas")
+  [1] "DATE9."
+attr(adsl_fmt$TRTEDT, "format.sas")
+  [1] "DATE9."
+attr(adsl_fmt$TRTSDTM, "format.sas")
+  [1] "DATETIME20."
+attr(adsl_fmt$TRTEDTM, "format.sas")
+  [1] "DATETIME20."
-
-

-xportr_varnames

+
+

xportr_label() +


-

There are several constraints placed upon variable naming. According to modern CDISC Implementation guides and the latest FDA conformance guide, all ADaM variable names must be:

-
    -
  1. no more than 8 characters in length

  2. -
  3. start with a letter (not an underscore)

  4. -
  5. be comprised of only uppercase letters (A-Z), numerals (0-9)

  6. -
  7. free of non-ASCII text, symbols, or underscores. Note: Underscores are permitted only for legacy studies started on or before Dec 17th, 2016

  8. -
-

For strings containing variable names xportr_tidy_rename() was designed to identify and rename variables into compliance. Thus, you can use this function to rename the spec file variables or column names on the fly. Below, we use it’s default options to tidy names for submission compliance.

-
renamed_var_spec <- var_spec %>%
-  filter(dataset == "ADSL") %>%
-  mutate(tidy_variable = xportr_tidy_rename(variable)
-  ) %>%
-  select(order, dataset, variable, tidy_variable, tidyselect::everything())
-  
-  The following variable name validation checks failed:
-  * Cannot contain any lowercase characters Variables `POPyFL`, `REGIONy`, `COVARy`, `STRATy`, `STRATyN`, `RACEGRy`, `RACEGRyN`, `RFICyDT`, `TRxxAGy`, `TRxxAGyN`, `EXNPxxM`, `EXNPxxMC`, `FENOBLGy`, `EOSBLGy`, `ICSENTGx`, and `OCSENTGx`.
-  
-  ── 16 of 124 (12.9%) variables were renamed ──
-  
-  Var 20:  'POPyFL' was renamed to 'POPYFL'
-  Var 58:  'REGIONy' was renamed to 'REGIONY'
-  Var 64:  'COVARy' was renamed to 'COVARY'
-  Var 104:  'STRATy' was renamed to 'STRATY'
-  Var 105:  'STRATyN' was renamed to 'STRATYN'
-  Var 110:  'RACEGRy' was renamed to 'RACEGRY'
-  Var 111:  'RACEGRyN' was renamed to 'RACEGRYN'
-  Var 112:  'RFICyDT' was renamed to 'RFICYDT'
-  Var 113:  'TRxxAGy' was renamed to 'TRXXAGY'
-  Var 114:  'TRxxAGyN' was renamed to 'TRXXAGYN'
-  Var 118:  'EXNPxxM' was renamed to 'EXNPXXM'
-  Var 119:  'EXNPxxMC' was renamed to 'EXNPXXMC'
-  Var 120:  'FENOBLGy' was renamed to 'FENOBLGY'
-  Var 121:  'EOSBLGy' was renamed to 'EOSBLGY'
-  Var 122:  'ICSENTGx' was renamed to 'ICSENTGX'
-  Var 124:  'OCSENTGx' was renamed to 'OCSENTGX'
-  
-  All renamed variables passed validation.
-

Note the above messages detail the rule(s) and variable names that were out of compliance, the number of renamed variables, and even the old and newly tidied names. The function uses a step-wise renaming algorithm to maintain the original variable names characteristics as much as possible. Below is the view of the the old variable names juxtaposed the new.

+

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 variable label.

+
look_for(adsl, details = FALSE)
+   pos variable label                             
+    1  STUDYID  Study Identifier                  
+    2  USUBJID  Unique Subject Identifier         
+    3  SUBJID   Subject Identifier for the Study  
+    4  RFSTDTC  Subject Reference Start Date/Time 
+    5  RFENDTC  Subject Reference End Date/Time   
+    6  RFXSTDTC Date/Time of First Study Treatment
+    7  RFXENDTC Date/Time of Last Study Treatment 
+    8  RFICDTC  Date/Time of Informed Consent     
+    9  RFPENDTC Date/Time of End of Participation 
+   10  DTHDTC   Date/Time of Death                
+   11  DTHFL    Subject Death Flag                
+   12  SITEID   Study Site Identifier             
+   13  AGE      Age                               
+   14  AGEU     Age Units                         
+   15  SEX      Sex                               
+   16  RACE     Race                              
+   17  ETHNIC   Ethnicity                         
+   18  ARMCD    Planned Arm Code                  
+   19  ARM      Description of Planned Arm        
+   20  ACTARMCD Actual Arm Code                   
+   21  ACTARM   Description of Actual Arm         
+   22  COUNTRY  Country                           
+   23  DMDTC    Date/Time of Collection           
+   24  DMDY     Study Day of Collection           
+   25  TRT01P   Description of Planned Arm        
+   26  TRT01A   Description of Actual Arm         
+   27  TRTSDTM  —                                 
+   28  TRTEDTM  —                                 
+   29  TRTSDT   —                                 
+   30  TRTEDT   —                                 
+   31  TRTDURD  —                                 
+   32  SCRFDT   —                                 
+   33  EOSDT    —                                 
+   34  EOSSTT   —                                 
+   35  FRVDT    —                                 
+   36  DTHDT    —                                 
+   37  DTHDTF   —                                 
+   38  DTHADY   —                                 
+   39  LDDTHELD —                                 
+   40  LSTALVDT —                                 
+   41  AGEGR1   —                                 
+   42  SAFFL    —                                 
+   43  RACEGR1  —                                 
+   44  REGION1  —                                 
+   45  LDDTHGR1 —                                 
+   46  DTH30FL  —                                 
+   47  DTHA30FL —                                 
+   48  DTHB30FL —


-
-

The function xportr_varnames() takes xportr_tidy_rename a step further to help users change the data.frame columns directly. It also is slightly less flexible from a customization perspective, attempting to follow the submission constraints precisely where as xportr_tidy_rename can be used for a wider breadth of renaming applications. Executing the code below, we create a new data.frame called adsl_renamed, but the variable names are already compliant. The identical function below shows us that nothing has changed.

-
adsl_renamed <- adsl %>% xportr_varnames()
-  
-  Variable Name Validation passed! No renaming necessary.
-  
-  ── 0 of 23 (0%) variables were renamed ──
-  
-identical(adsl, adsl_renamed)
-  [1] TRUE
-

In the interest of showcasing xportr_varnames capabilities, we create a fictional data.frame adxx riddled with non-compliant variable names below. In fact, adxx only has one valid variable name: “STUDYID”. Calling the function shows this data.frame’s variables violate all four compliance rules and proceeds to rename all but “STUDYID”.

-
varnames <- c("", "STUDYID", "studyid", "subject id", "1c. ENT", "1b. Eyes",
-      "1d. Lungs", "1e. Heart", "year number", "1a. Skin_Desc")
-adxx <- data.frame(matrix(0, ncol = 10, nrow = 3))
-colnames(adxx) <- varnames
-
-xportr_varnames(adxx) # default behavior
-  
-  The following variable name validation checks failed:
-  * Must be 8 characters or less: Variables `subject id`, `1d. Lungs`, `1e. Heart`, `year number`, and `1a. Skin_Desc`.
-  * Must start with a letter: Variables `1c. ENT`, `1b. Eyes`, `1d. Lungs`, `1e. Heart`, and `1a. Skin_Desc`.
-  * Cannot contain any non-ASCII, symbol or underscore characters: Variables `subject id`, `1c. ENT`, `1b. Eyes`, `1d. Lungs`, `1e. Heart`, `year number`, and `1a. Skin_Desc`.
-  * Cannot contain any lowercase characters Variables ``, `studyid`, `subject id`, `1c. ENT`, `1b. Eyes`, `1d. Lungs`, `1e. Heart`, `year number`, and `1a. Skin_Desc`.
-  
-  ── 9 of 10 (90%) variables were renamed ──
-  
-  Var 1:  '' was renamed to 'V1'
-  Var 3:  'studyid' was renamed to 'STUDYID2'
-  Var 4:  'subject id' was renamed to 'SUBJECTD'
-  Var 5:  '1c. ENT' was renamed to 'ENT1C'
-  Var 6:  '1b. Eyes' was renamed to 'EYES1B'
-  Var 7:  '1d. Lungs' was renamed to 'LUNGS1D'
-  Var 8:  '1e. Heart' was renamed to 'HEART1E'
-  Var 9:  'year number' was renamed to 'YEARNUMB'
-  Var 10:  '1a. Skin_Desc' was renamed to 'SKNDSC1A'
-  
-  All renamed variables passed validation.
-    V1 STUDYID STUDYID2 SUBJECTD ENT1C EYES1B LUNGS1D HEART1E YEARNUMB SKNDSC1A
-  1  0       0        0        0     0      0       0       0        0        0
-  2  0       0        0        0     0      0       0       0        0        0
-  3  0       0        0        0     0      0       0       0        0        0
-

You may have observed in the previous output that all variables starting with a number were bundled and relocated to the END of the term. For example, 1d. Lungs" became “LUNGS1D”. To maintain the numeric prefix at the start (or left-hand side), users can set a letter [A-Z] to prefix the numeric prefix. Below we set letter_for_num_prefix to “x” and relo_2_end to FALSE.

-

Second, if your organization holds an ontology of controlled terms, you can then map non-compliant variable names to any desired result using the dict_dat argument. It’s essentially provides a “find any replace” functionality for any instance of the term(s) found in the data. In the example below, we want “subject id” to be portrayed as “SUBJID”. Thus, we created a data.frame called my_dictionary that maps that relationship.

-
my_dictionary <- data.frame(original_varname = "subject id", dict_varname = "SUBJID")
-xportr_varnames(adxx,
-                   relo_2_end = FALSE,
-                   letter_for_num_prefix = "x",
-                   dict_dat  = my_dictionary) # 'SUBJID' used
-  
-  The following variable name validation checks failed:
-  * Must be 8 characters or less: Variables `subject id`, `1d. Lungs`, `1e. Heart`, `year number`, and `1a. Skin_Desc`.
-  * Must start with a letter: Variables `1c. ENT`, `1b. Eyes`, `1d. Lungs`, `1e. Heart`, and `1a. Skin_Desc`.
-  * Cannot contain any non-ASCII, symbol or underscore characters: Variables `subject id`, `1c. ENT`, `1b. Eyes`, `1d. Lungs`, `1e. Heart`, `year number`, and `1a. Skin_Desc`.
-  * Cannot contain any lowercase characters Variables ``, `studyid`, `subject id`, `1c. ENT`, `1b. Eyes`, `1d. Lungs`, `1e. Heart`, `year number`, and `1a. Skin_Desc`.
-  
-  ── 9 of 10 (90%) variables were renamed ──
-  
-  Var 1:  '' was renamed to 'V1'
-  Var 3:  'studyid' was renamed to 'STUDYID2'
-  Var 4:  'subject id' was renamed to 'SUBJID'
-  Var 5:  '1c. ENT' was renamed to 'X1CENT'
-  Var 6:  '1b. Eyes' was renamed to 'X1BEYES'
-  Var 7:  '1d. Lungs' was renamed to 'X1DLUNGS'
-  Var 8:  '1e. Heart' was renamed to 'X1EHEART'
-  Var 9:  'year number' was renamed to 'YEARNUMB'
-  Var 10:  '1a. Skin_Desc' was renamed to 'X1SKNDSC'
-  
-  All renamed variables passed validation.
-    V1 STUDYID STUDYID2 SUBJID X1CENT X1BEYES X1DLUNGS X1EHEART YEARNUMB X1SKNDSC
-  1  0       0        0      0      0       0        0        0        0        0
-  2  0       0        0      0      0       0        0        0        0        0
-  3  0       0        0      0      0       0        0        0        0        0
-

Please review the documentation using ?xportr_tidy_rename OR ?xportr_varnames to learn how the abbreviation algorithm works and to further customize the renaming of your variable names using a slurry of additional arguments.

+

Using the xport_label function we can take the +specifications file and label all the variables available. +xportr_label will produce a warning message if you the +variable in the data set is not in the specification file.


+
+adsl_update <- adsl %>% xportr_label(var_spec, domain = "ADSL", "message")
+
look_for(adsl_update, details = FALSE)
+   pos variable label                                  
+    1  STUDYID  Study Identifier                       
+    2  USUBJID  Unique Subject Identifier              
+    3  SUBJID   Subject Identifier for the Study       
+    4  RFSTDTC  Subject Reference Start Date/Time      
+    5  RFENDTC  Subject Reference End Date/Time        
+    6  RFXSTDTC Date/Time of First Study Treatment     
+    7  RFXENDTC Date/Time of Last Study Treatment      
+    8  RFICDTC  Date/Time of Informed Consent          
+    9  RFPENDTC Date/Time of End of Participation      
+   10  DTHDTC   Date / Time of Death                   
+   11  DTHFL    Subject Death Flag                     
+   12  SITEID   Study Site Identifier                  
+   13  AGE      Age                                    
+   14  AGEU     Age Units                              
+   15  SEX      Sex                                    
+   16  RACE     Race                                   
+   17  ETHNIC   Ethnicity                              
+   18  ARMCD    Planned Arm Code                       
+   19  ARM      Description of Planned Arm             
+   20  ACTARMCD Actual Arm Code                        
+   21  ACTARM   Description of Actual Arm              
+   22  COUNTRY  Country                                
+   23  DMDTC    Date/Time of Collection                
+   24  DMDY     Study Day of Collection                
+   25  TRT01P   Planned Treatment for Period 01        
+   26  TRT01A   Actual Treatment for Period 01         
+   27  TRTSDTM  Datetime of First Exposure to Treatment
+   28  TRTEDTM  Datetime of Last Exposure to Treatment 
+   29  TRTSDT   Date of First Exposure to Treatment    
+   30  TRTEDT   Date of Last Exposure to Treatment     
+   31  TRTDURD  Total Duration of Trt  (days)          
+   32  SCRFDT   Screen Failure Date                    
+   33  EOSDT    End of Study Date                      
+   34  EOSSTT   End of Study Status                    
+   35  FRVDT    Final Retrievel Visit Date             
+   36  DTHDT    Death Date                             
+   37  DTHDTF   Date of Death Imputation Flag          
+   38  DTHADY   Relative Day of Death                  
+   39  LDDTHELD Elapsed Days from Last Dose to Death   
+   40  LSTALVDT Date Last Known Alive                  
+   41  AGEGR1   Pooled Age Group 1                     
+   42  SAFFL    Safety Population Flag                 
+   43  RACEGR1  Pooled Race Group 1                    
+   44  REGION1  Geographic Region 1                    
+   45  LDDTHGR1 Last Does to Death Group               
+   46  DTH30FL  Under 30  Group                        
+   47  DTHA30FL Over 30  Group                         
+   48  DTHB30FL Over 30 plus 30 days Group
-
-

-xportr_write

+
+

xportr_write() +


-

Finally, we arrive at exporting the R data frame object as a xpt file with the function xportr_write. The xpt file will be written directly to your current working directory. To make it more interesting, we have put together all five function with the magrittr pipe. A user can now coerce, apply length, variable labels, data set label and write out their final xpt file in one pipe! Appropriate warnings and messages will be supplied to a user for any potential issues before sending off to standard clinical data set validator application or data reviewers.

-
-  
-adsl %>%
-  xportr_type(var_spec, "ADSL", "message") %>%
-  xportr_length(var_spec, "ADSL", "message") %>%
-  xportr_label(var_spec, "ADSL", "message") %>%
-  xportr_df_label(data_spec, "ADSL") %>%
-  xportr_varnames("message") %>%
-  xportr_write("adsl.xpt")
-

Optionally, leave out xportr_varnames and instead use tidy_varnames = TRUE in xportr_write() to accept the recommended defaults of xportr_tidy_rename.

-
-# No xportr_varnames()!
-adsl %>%
-  xportr_type(var_spec, "ADSL", "message") %>%
-  xportr_length(var_spec, "ADSL", "message") %>%
-  xportr_label(var_spec, "ADSL", "message") %>%
-  xportr_df_label(data_spec, "ADSL") %>%
-  xportr_write("adsl.xpt", tidy_varnames = TRUE)
+

Finally, we arrive at exporting the R data frame object as a xpt file +with the function xportr_write(). The xpt file will be +written directly to your current working directory. To make it more +interesting, we have put together all six functions with the magrittr +pipe, %>%. A user can now apply types, length, variable +labels, formats, data set label and write out their final xpt file in +one pipe! Appropriate warnings and messages will be supplied to a user +to the console for any potential issues before sending off to standard +clinical data set validator application or data reviewers.

+
+adsl %>%
+  xportr_type(var_spec, "ADSL", "message") %>%
+  xportr_length(var_spec, "ADSL", "message") %>%
+  xportr_label(var_spec, "ADSL", "message") %>%
+  xportr_order(var_spec, "ADSL", "message") %>% 
+  xportr_format(var_spec, "ADSL", "message") %>% 
+  xportr_write("adsl.xpt", label = "Subject-Level Analysis Dataset")
+

That’s it! We now have a xpt file created in R with all appropriate +types, lengths, labels, ordering and formats from our specification +file.

+

As always, we welcome your feedback. If you spot a bug, would like to +see a new feature, or if any documentation is unclear - submit an issue +on xportr’s +Github page.

@@ -527,11 +702,13 @@

-

Site built with pkgdown 1.6.1.

+

+

Site built with pkgdown 2.0.3.

@@ -540,5 +717,7 @@

+ + diff --git a/docs/authors.html b/docs/authors.html index c87fb954..6680e2f9 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,75 +1,12 @@ - - - - - - - -Authors • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Authors and Citation • xportr - + + - - - - -
-
-
- -
+
- @@ -154,22 +98,20 @@

Authors

-
- +
- - + + diff --git a/docs/index.html b/docs/index.html index aca1bbff..68476df5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -18,7 +18,7 @@ - + + +
-
- - - + + diff --git a/docs/reference/xportr_format.html b/docs/reference/xportr_format.html index d7cb78bb..9b582f78 100644 --- a/docs/reference/xportr_format.html +++ b/docs/reference/xportr_format.html @@ -1,76 +1,12 @@ - - - - - - - -SAS format — xportr_format • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Assign SAS Format — xportr_format • xportr - - + + - - -
-
- -
- -
+
-

Assigns SAS format from a variable level metadata to a given data frame.

+

Assigns a SAS format from a variable level metadata to a given data frame.

-
xportr_format(
-  .df,
-  metacore,
-  domain = NULL,
-  verbose = getOption("xportr.format_verbose", "none")
-)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
.df

A data frame of CDISC standard.

metacore

A data frame containing variable level metadata.

domain

A character value to subset the .df. If NULL(default), uses -.df value as a subset condition.

verbose

The action the function takes when a variable label isn't. -found. Options are 'stop', 'warn', 'message', and 'none'

- -

Value

+
+
xportr_format(
+  .df,
+  metacore,
+  domain = NULL,
+  verbose = getOption("xportr.format_verbose", "none")
+)
+
+
+

Arguments

+
.df
+

A data frame of CDISC standard.

+
metacore
+

A data frame containing variable level metadata.

+
domain
+

A character value to subset the .df. If NULL(default), uses +.df value as a subset condition.

+
verbose
+

The action the function takes when a variable label isn't. +found. Options are 'stop', 'warn', 'message', and 'none'

+
+
+

Value

Data frame with SASformat attributes for each variable.

-

See also

- - +
+

See also

+ - -

Examples

-
adsl <- data.frame( - USUBJID = c(1001, 1002, 1003), - BRTHDT = c(1, 1, 2) -) - -metacore <- data.frame( - dataset = c("adsl", "adsl"), - variable = c("USUBJID", "BRTHDT"), - format = c(NA, "DATE9.") -) - -adsl <- xportr_format(adsl, metacore) -
+xportr_df_label(), +xportr_label(), +xportr_length()

+
+ +
+

Examples

+
adsl <- data.frame(
+  USUBJID = c(1001, 1002, 1003),
+  BRTHDT = c(1, 1, 2)
+)
+
+metacore <- data.frame(
+  dataset = c("adsl", "adsl"),
+  variable = c("USUBJID", "BRTHDT"),
+  format = c(NA, "DATE9.")
+)
+
+adsl <- xportr_format(adsl, metacore)
+
+
+
-
- +
- - + + diff --git a/docs/reference/xportr_label.html b/docs/reference/xportr_label.html index 2cef576a..9d3787e2 100644 --- a/docs/reference/xportr_label.html +++ b/docs/reference/xportr_label.html @@ -1,76 +1,12 @@ - - - - - - - -Variable label — xportr_label • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Assign Variable Label — xportr_label • xportr - - + + - - -
-
- -
- -
+
@@ -132,88 +55,80 @@

Variable label

Assigns variable label from a variable level metadata to a given data frame.

-
xportr_label(
-  .df,
-  metacore,
-  domain = NULL,
-  verbose = getOption("xportr.label_verbose", "none")
-)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
.df

A data frame of CDISC standard.

metacore

A data frame containing variable level metadata.

domain

A character value to subset the .df. If NULL(default), uses -.df value as a subset condition.

verbose

The action the function takes when a variable length isn't -Found. Options are 'stop', 'warn', 'message', and 'none'

- -

Value

+
+
xportr_label(
+  .df,
+  metacore,
+  domain = NULL,
+  verbose = getOption("xportr.label_verbose", "none")
+)
+
+
+

Arguments

+
.df
+

A data frame of CDISC standard.

+
metacore
+

A data frame containing variable level metadata.

+
domain
+

A character value to subset the .df. If NULL(default), uses +.df value as a subset condition.

+
verbose
+

The action the function takes when a variable length isn't +Found. Options are 'stop', 'warn', 'message', and 'none'

+
+
+

Value

Data frame with label attributes for each variable.

-

See also

- - +
+

See also

+ - -

Examples

-
adsl <- data.frame( - USUBJID = c(1001, 1002, 1003), - SITEID = c(001, 002, 003), - AGE = c(63, 35, 27), - SEX = c("M", "F", "M") -) - -metacore <- data.frame( - dataset = "adsl", - variable = c("USUBJID", "SITEID", "AGE", "SEX"), - label = c("Unique Subject Identifier", "Study Site Identifier", "Age", "Sex") -) - -adsl <- xportr_label(adsl, metacore) -
+xportr_df_label(), +xportr_format(), +xportr_length()

+
+ +
+

Examples

+
adsl <- data.frame(
+  USUBJID = c(1001, 1002, 1003),
+  SITEID = c(001, 002, 003),
+  AGE = c(63, 35, 27),
+  SEX = c("M", "F", "M")
+)
+
+metacore <- data.frame(
+  dataset = "adsl",
+  variable = c("USUBJID", "SITEID", "AGE", "SEX"),
+  label = c("Unique Subject Identifier", "Study Site Identifier", "Age", "Sex")
+)
+
+adsl <- xportr_label(adsl, metacore)
+
+
+
-
- +
- - + + diff --git a/docs/reference/xportr_length.html b/docs/reference/xportr_length.html index 0e7539d4..51a2aba4 100644 --- a/docs/reference/xportr_length.html +++ b/docs/reference/xportr_length.html @@ -1,76 +1,12 @@ - - - - - - - -SAS Length — xportr_length • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Assign SAS Length — xportr_length • xportr - - + + - - -
-
- -
- -
+
@@ -132,86 +55,78 @@

SAS Length

Assigns SAS length from a variable level metadata to a given data frame.

-
xportr_length(
-  .df,
-  metacore,
-  domain = NULL,
-  verbose = getOption("xportr.length_verbose", "none")
-)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
.df

A data frame of CDISC standard.

metacore

A data frame containing variable level metadata.

domain

A character value to subset the .df. If NULL(default), uses -.df value as a subset condition.

verbose

The action the function takes when a length isn't found in -metadata. Options are 'stop', 'warn', 'message', and 'none'

- -

Value

+
+
xportr_length(
+  .df,
+  metacore,
+  domain = NULL,
+  verbose = getOption("xportr.length_verbose", "none")
+)
+
+
+

Arguments

+
.df
+

A data frame of CDISC standard.

+
metacore
+

A data frame containing variable level metadata.

+
domain
+

A character value to subset the .df. If NULL(default), uses +.df value as a subset condition.

+
verbose
+

The action the function takes when a length isn't found in +metadata. Options are 'stop', 'warn', 'message', and 'none'

+
+
+

Value

Data frame with SASlength attributes for each variable.

-

See also

- - +
+

See also

+ - -

Examples

-
adsl <- data.frame( - USUBJID = c(1001, 1002, 1003), - BRTHDT = c(1, 1, 2) -) - -metacore <- data.frame( - dataset = c("adsl", "adsl"), - variable = c("USUBJID", "BRTHDT"), - length = c(10, 8) -) - -adsl <- xportr_length(adsl, metacore) -
+xportr_df_label(), +xportr_format(), +xportr_label()

+
+ +
+

Examples

+
adsl <- data.frame(
+  USUBJID = c(1001, 1002, 1003),
+  BRTHDT = c(1, 1, 2)
+)
+
+metacore <- data.frame(
+  dataset = c("adsl", "adsl"),
+  variable = c("USUBJID", "BRTHDT"),
+  length = c(10, 8)
+)
+
+adsl <- xportr_length(adsl, metacore)
+
+
+
-
- +
- - + + diff --git a/docs/reference/xportr_order.html b/docs/reference/xportr_order.html index a5df4e1f..5a75a97a 100644 --- a/docs/reference/xportr_order.html +++ b/docs/reference/xportr_order.html @@ -1,76 +1,12 @@ - - - - - - - -Order variables of a dataset according to Spec — xportr_order • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Order variables of a dataset according to Spec — xportr_order • xportr - + + - - - -
-
- -
- -
+
@@ -132,64 +55,53 @@

Order variables of a dataset according to Spec

Order variables of a dataset according to Spec

-
xportr_order(
-  .df,
-  metacore,
-  domain = NULL,
-  verbose = getOption("xportr.order_verbose", "none")
-)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
.df

A data frame of CDISC standard.

metacore

A data frame containing variable level metadata.

domain

A character value to subset the .df. If NULL(default), uses -.df value as a subset condition.

verbose

Option for messaging order results

- -

Value

+
+
xportr_order(
+  .df,
+  metacore,
+  domain = NULL,
+  verbose = getOption("xportr.order_verbose", "none")
+)
+
+
+

Arguments

+
.df
+

A data frame of CDISC standard.

+
metacore
+

A data frame containing variable level metadata.

+
domain
+

A character value to subset the .df. If NULL(default), uses +.df value as a subset condition.

+
verbose
+

Option for messaging order results

+
+
+

Value

Dataframe that has been re-ordered according to spec

+
+
-
- +
- - + + diff --git a/docs/reference/xportr_type.html b/docs/reference/xportr_type.html index 1e4f009f..0166b8cb 100644 --- a/docs/reference/xportr_type.html +++ b/docs/reference/xportr_type.html @@ -1,77 +1,13 @@ - - - - - - - -Coerce variable type — xportr_type • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Coerce variable type — xportr_type • xportr - - + + - - -
-
- -
- -
+
@@ -134,84 +57,79 @@

Coerce variable type

columns_meta is a data.frame with names "Variables", "Type"

-
xportr_type(
-  .df,
-  metacore,
-  domain = NULL,
-  verbose = getOption("xportr.type_verbose", "none")
-)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
.df

An R object with columns that can be coerced

metacore

Either a data.frame that has the names of all possible columns +

+
xportr_type(
+  .df,
+  metacore,
+  domain = NULL,
+  verbose = getOption("xportr.type_verbose", "none")
+)
+
+ +
+

Arguments

+
.df
+

An R object with columns that can be coerced

+
metacore
+

Either a data.frame that has the names of all possible columns and their types, or a Metacore object from the Metacore package. Required -column names are dataset, variables, type

domain

Name of the dataset. Ex ADAE/DM. This will be used to subset +column names are dataset, variables, type

+
domain
+

Name of the dataset. Ex ADAE/DM. This will be used to subset the metacore object. If none is passed it is assumed to be the name of the -dataset passed in .df.

verbose

The action the function takes when a variable isn't typed -properly. Options are 'stop', 'warn', 'message', and 'none'

- -

Value

- +dataset passed in .df.

+
verbose
+

The action the function takes when a variable isn't typed +properly. Options are 'stop', 'warn', 'message', and 'none'

+
+
+

Value

Returns the modified table.

+
-

Examples

-
metacore <- data.frame( - dataset = "test", - variable = c("Subj", "Param", "Val", "NotUsed"), - type = c("numeric", "character", "numeric", "character") -) - -.df <- data.frame( - Subj = as.character(123, 456, 789), - Different = c("a", "b", "c"), - Val = c("1", "2", "3"), - Param = c("param1", "param2", "param3") -) - -df2 <- xportr_type(.df, metacore, "test") -
#> ── Variable type mismatches found. ──
#>
#> 2 variables coerced
+
+

Examples

+
metacore <- data.frame(
+  dataset = "test",
+  variable = c("Subj", "Param", "Val", "NotUsed"),
+  type = c("numeric", "character", "numeric", "character")
+)
+
+.df <- data.frame(
+ Subj = as.character(123, 456, 789),
+ Different = c("a", "b", "c"),
+ Val = c("1", "2", "3"),
+ Param = c("param1", "param2", "param3")
+)
+
+df2 <- xportr_type(.df, metacore, "test")
+#> 
+#> ── Variable type mismatches found. ──
+#> 
+#>  2 variables coerced
+
+
+
-
- +
- - + + diff --git a/docs/reference/xportr_write.html b/docs/reference/xportr_write.html index c182f151..28348a6f 100644 --- a/docs/reference/xportr_write.html +++ b/docs/reference/xportr_write.html @@ -1,78 +1,14 @@ - - - - - - - -Write SAS transport file — xportr_write • xportr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Write xpt v5 transport file — xportr_write • xportr - - - - + + -
-
- -
- -
+

Writes a local data frame into SAS transport file of version 5. The SAS -transport format is a open format, as is required for submission of the data +transport format is an open format, as is required for submission of the data to the FDA.

-
xportr_write(.df, path, label = NULL, tidy_names = FALSE)
- -

Arguments

- - - - - - - - - - - - - - - - - - -
.df

A data frame to write.

path

Path where transport file will be written. File name sans will be -used as xpt name.

label

Dataset label. It must be<=40 characters.

tidy_names

logical, if TRUE the .df variable names will be -automatically renamed to conform to the submission guidelines.

- -

Value

- -

A data frame. write_xport() returns the input data invisibly.

-

Details

+
+
xportr_write(.df, path, label = NULL)
+
+
+

Arguments

+
.df
+

A data frame to write.

+
path
+

Path where transport file will be written. File name sans will be +used as xpt name.

+
label
+

Dataset label. It must be<=40 characters.

+
+
+

Value

+

A data frame. xportr_write() returns the input data invisibly.

+
+
+

Details

-
    -
  • Variable and dataset labels are stored in the "label" attribute.

  • +
    • Variable and dataset labels are stored in the "label" attribute.

    • SAS length are stored in the "SASlength" attribute.

    • SAS format are stored in the "SASformat" attribute.

    • SAS type are stored in the "SAStype" attribute.

    • -
    - +
-

Examples

-
tmp <- file.path(tempdir(), "mtcars.xpt") -xportr_write(mtcars, tmp, label = "Motor Trend Car Road Tests") -
+
-
- - + + diff --git a/vignettes/xportr.Rmd b/vignettes/xportr.Rmd index d4a350ae..8df23271 100644 --- a/vignettes/xportr.Rmd +++ b/vignettes/xportr.Rmd @@ -20,7 +20,6 @@ library(DT) ``` ```{r, include=FALSE} -options(width = 60) local({ hook_output <- knitr::knit_hooks$get('output') knitr::knit_hooks$set(output = function(x, options) {