xportr_write {xportr} | R Documentation |
Write xpt v5 transport file
Description
Writes a local data frame into SAS transport file of version 5. The SAS transport format is an open format, as is required for submission of the data to the FDA.
Usage
xportr_write(
.df,
path,
metadata = NULL,
domain = NULL,
strict_checks = FALSE,
label = deprecated()
)
Arguments
Details
Variable and dataset labels are stored in the "label" attribute.
SAS format are stored in the "SASformat" attribute.
SAS type are based on the
metadata
attribute.
Value
A data frame. xportr_write()
returns the input data invisibly.
Metadata
The argument passed in the 'metadata' argument can either be a metacore object, or a data.frame containing the data listed below. If metacore is used, no changes to options are required.
For data.frame 'metadata' arguments two columns must be present:
Domain Name - passed as the 'xportr.df_domain_name' option. Default: "dataset". This is the column subset by the 'domain' argument in the function.
Label Name - passed as the 'xportr.df_label' option. Default: "label". Character values to update the 'label' attribute of the dataframe This is passed to
haven::write_xpt
to note the label.
Examples
adsl <- data.frame(
SUBL = as.character(123, 456, 789),
DIFF = c("a", "b", "c"),
VAL = c("1", "2", "3"),
PARAM = c("param1", "param2", "param3")
)
var_spec <- data.frame(
dataset = "adsl",
label = "Subject-Level Analysis Dataset",
data_label = "ADSL"
)
xportr_write(adsl,
path = paste0(tempdir(), "/adsl.xpt"),
domain = "adsl",
metadata = var_spec,
strict_checks = FALSE
)