
Welcome toxportr! We have designedxportrto help get your xpt files ready for transport either to a clinical dataset validator application or to a regulatory agency. This package hasthe functionality to associate metadata information to a local R dataframe, perform data set level validation checks and convert into atransportv5 file(xpt).
As always, we welcome your feedback. If you spot a bug, would like tosee a new feature, or if any documentation is unclear - submit an issueonxportr’sGitHub page.
This package is available from CRAN and can be installed byrunning:
install.packages("xportr")install.packages("xportr",repos =c("https://pharmaverse.r-universe.dev",getOption("repos")))xportr is designed for clinical programmers to createCDISC compliant xpt files-ADaM orSDTM. Essentially, this package has two big componentsto it
The first set of tools are designed to allow a clinical programmer tobuild a CDISC compliant xpt file directly from R. The second set oftools are to perform checks on your data sets before you send them offto any validators or data reviewers.

NOTE: Each check has associated messages andwarning.
Objective: Create a fully compliant v5 xptADSL 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 andthe{xportr} package!
First we will start with ourADSL dataset created in R.This exampleADSL dataset contains 306 observations and 51variables.
library(dplyr)library(xportr)data("adsl_xportr")ADSL<- adsl_xportrWe have created a dummy specification file calledADaM_spec.xlsx found in thespecs folder ofthis package. You can usesystem.file(file.path("specs/", "ADaM_spec.xlsx"), package = "xportr")to access this file.
spec_path<-system.file(file.path("specs","ADaM_spec.xlsx"),package ="xportr")var_spec<- readxl::read_xlsx(spec_path,sheet ="Variables")%>% dplyr::rename(type ="Data Type")%>% dplyr::rename_with(tolower)dataset_spec<- readxl::read_xlsx(spec_path,sheet ="Datasets")%>% dplyr::rename(label ="Description")%>% dplyr::rename_with(tolower)Eachxportr_ function has been written in a way to takein a part of the specification file and apply that piece to the dataset.Settingverbose = "warn" will send appropriate warningmessage to the console. We have suppressed the warning for the sake ofbrevity.
ADSL%>%xportr_metadata(var_spec,"ADSL")%>%xportr_type(verbose ="warn")%>%xportr_length(verbose ="warn")%>%xportr_label(verbose ="warn")%>%xportr_order(verbose ="warn")%>%xportr_format()%>%xportr_df_label(dataset_spec,"ADSL")%>%xportr_write("adsl.xpt")Thexportr_metadata() function can reduce duplication bysetting the variable specification and domain explicitly at the top of apipeline. If you would like to use theverbose argument,you will need to set in each function call.
ADSL%>%xportr_metadata(var_spec,"ADSL",verbose ="warn")%>%xportr_type()%>%xportr_length()%>%xportr_label()%>%xportr_order()%>%xportr_format()%>%xportr_df_label(dataset_spec)%>%xportr_write("adsl.xpt")Furthermore, if you’re calling all xportr functions at once withcommon metadata and verbosity, you can shorten it by simply usingxportr().
xportr(.df = ADSL,var_metadata = var_spec,df_metadata = dataset_spec,domain ="ADSL",verbose ="warn","adsl.xpt")That’s it! We now have a xpt file created in R with all appropriatetypes, lengths, labels, ordering and formats. Please check out theGetStarted for more information and detailed walk through of eachxportr_ function.
We are in talks with other Pharma companies involved with the{pharmaverse} toenhance this package to play well with other downstream and upstreampackages.
This package was developed jointly byGSK andAtorus.