Welcome to xportr
! We have designed xportr
to help get your xpt files ready for transport either to a clinical data
set validator application or to a regulatory agency. This package has
the functionality to associate metadata information to a local R data
frame, perform data set level validation checks and convert into a transport
v5 file(xpt).
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.
::install_github("https://github.com/atorus-research/xportr.git", ref = "main") devtools
xportr
is designed for clinical programmers to create
CDISC compliant xpt files- ADaM or
SDTM. Essentially, this package has two big components
to it
The first set of tools are designed to allow a clinical programmer to build a CDISC compliant xpt file directly from R. The second set of tools are to perform checks on your data sets before you send them off to any validators or data reviewers.
NOTE: Each check has associated messages and warning.
Objective: Create a fully compliant v5 xpt
ADSL
dataset that was developed using R.
To do this we will need to do the following:
All of which can be done using a well-defined specification file and
the xportr
package!
First we will start with our ADSL
dataset created in R.
This example ADSL
dataset is taken from the {admiral}
package. The script that generates this ADSL
dataset can be
created by using this command
admiral::use_ad_template("adsl")
. This ADSL
dataset has 306 observations and 48 variables.
library(dplyr)
library(admiral)
library(xportr)
<- admiral::admiral_adsl adsl
We have created a dummy specification file called
ADaM_admiral_spec.xlsx
found in the specs
folder of this package. You can use
system.file(paste0("specs/", "ADaM_admiral_spec.xlsx"), package = "xportr")
to access this file.
<- system.file(paste0("specs/", "ADaM_admiral_spec.xlsx"), package = "xportr")
spec_path
<- readxl::read_xlsx(spec_path, sheet = "Variables") %>%
var_spec ::rename(type = "Data Type") %>%
dplyr::set_names(tolower) rlang
Each xportr_
function has been written in a way to take
in a part of the specification file and apply that piece to the
dataset.
%>%
adsl xportr_type(var_spec, "ADSL") %>%
xportr_length(var_spec, "ADSL") %>%
xportr_label(var_spec, "ADSL") %>%
xportr_order(var_spec, "ADSL") %>%
xportr_format(var_spec, "ADSL") %>%
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. Please check out the Get
Started for more information and detailed walk through of each
xportr_
function.
We are in talks with other Pharma companies involved with the {pharmaverse}
to
enhance this package to play well with other downstream and upstream
packages.