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

.df

A data frame to write.

path

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

metadata

A data frame containing dataset. See 'Metadata' section for details.

domain

Appropriate CDISC dataset name, e.g. ADAE, DM. Used to subset the metadata object.

strict_checks

If TRUE, xpt validation will report errors and not write out the dataset. If FALSE, xpt validation will report warnings and continue with writing out the dataset. Defaults to FALSE

label

[Deprecated] Previously used to to set the Dataset label. Use the metadata argument to set the dataset label.

Details

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:

  1. Domain Name - passed as the 'xportr.df_domain_name' option. Default: "dataset". This is the column subset by the 'domain' argument in the function.

  2. 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
)


[Package xportr version 0.4.0 Index]