Title: | Validate SDTM Domains |
---|---|
Description: | Provides a set of tools to assist statistical programmers in validating Study Data Tabulation Model (SDTM) domain data sets. Statistical programmers are required to validate that a SDTM data set domain has been programmed correctly, per the SDTM Implementation Guide (SDTMIG) by 'CDISC' (<https://www.cdisc.org/standards/foundational/sdtmig>), study specification, and study protocol using a process called double programming. Double programming involves two different programmers independently converting the raw electronic data cut (EDC) data into a SDTM domain data table and comparing their results to ensure accurate standardization of the data. One of these attempts is termed 'production' and the other 'validation'. Generally, production runs are the official programs for submittals and these are written in 'SAS'. Validation runs can be programmed in another language, in this case 'R'. |
Authors: | Stephen Knapp [aut, cre, cph] |
Maintainer: | Stephen Knapp <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.1 |
Built: | 2025-02-15 05:10:55 UTC |
Source: | https://github.com/skgithub14/sdtmval |
Trims the length of each text and date variable to the length specified in
the spec and then assigns the attributes "label"
and "width"
to each
column.
assign_meta_data( tbl, spec, datatype_col = "Data Type", var_col = "Variable", length_col = "Length", label_col = "Label" )
assign_meta_data( tbl, spec, datatype_col = "Data Type", var_col = "Variable", length_col = "Length", label_col = "Label" )
tbl |
a data frame containing a SDTM table |
spec |
a data frame with the columns |
datatype_col |
a string, the column in |
var_col |
a string, the column in |
length_col |
a string, the column in |
label_col |
a string, the column in |
a modified copy of tbl
with the meta data per specification
get_data_spec()
, get_key_vars()
, get_codelist()
work_dir <- system.file("extdata", package = "sdtmval") spec <- get_data_spec(domain = "XX", dir = work_dir, filename = "spec.xlsx") after_meta_data <- assign_meta_data(sdtmval::xx_no_meta_data, spec = spec) labels <- colnames(after_meta_data) |> purrr::map(~ attr(after_meta_data[[.]], "label")) |> unlist() lengths <- colnames(after_meta_data) |> purrr::map(~ attr(after_meta_data[[.]], "width")) |> unlist() data.frame( column = colnames(after_meta_data), labels = labels, lengths = lengths )
work_dir <- system.file("extdata", package = "sdtmval") spec <- get_data_spec(domain = "XX", dir = work_dir, filename = "spec.xlsx") after_meta_data <- assign_meta_data(sdtmval::xx_no_meta_data, spec = spec) labels <- colnames(after_meta_data) |> purrr::map(~ attr(after_meta_data[[.]], "label")) |> unlist() lengths <- colnames(after_meta_data) |> purrr::map(~ attr(after_meta_data[[.]], "width")) |> unlist() data.frame( column = colnames(after_meta_data), labels = labels, lengths = lengths )
Assigns the "[DOMAIN]SEQ"
number by sorting the data set by the specified
variables and then grouping by "USUBJID"
.
assign_SEQ(tbl, key_vars, seq_prefix, USUBJID = "USUBJID")
assign_SEQ(tbl, key_vars, seq_prefix, USUBJID = "USUBJID")
tbl |
a data frame, the SDTM table |
key_vars |
a character vector of the key variables to sort by |
seq_prefix |
a string, the prefix for SEQ as per the spec (usually the two letter domain abbreviation) |
USUBJID |
a string, the column for the subject ID, USUBJID, default is
|
a sorted copy of the tbl
data frame with the new SEQ column
df <- data.frame( USUBJID = paste("Subject", c(rep(1, 3), rep(2, 3))), XXTESTCD = paste("T", rep(c(2, 3, 1), 2)) ) assign_SEQ(df, key_vars = c("USUBJID", "XXTESTCD"), seq_prefix = "XX")
df <- data.frame( USUBJID = paste("Subject", c(rep(1, 3), rep(2, 3))), XXTESTCD = paste("T", rep(c(2, 3, 1), 2)) ) assign_SEQ(df, key_vars = c("USUBJID", "XXTESTCD"), seq_prefix = "XX")
Utilizes the DY method from the SDTM spec: --DTC-RFSTDTC+1
if --DTC
is on
or after RFSTDTC. --DTC-RFSTDTC
if --DTC
precedes RFSTDTC
. This
function can also be used for the ENDY method from the spec which has the
same logic.
calc_DY(tbl, DY_col, DTC_col, RFSTDTC = "RFSTDTC")
calc_DY(tbl, DY_col, DTC_col, RFSTDTC = "RFSTDTC")
tbl |
a data frame with the date column |
DY_col |
string, the name of the new DY column to create |
DTC_col |
string, the column in |
RFSTDTC |
a string, the column to use for |
a modified copy of tbl
with the new DY column
df <- data.frame( DTC = c("2023-08-01", "2023-08-02", "2023-08-03", "2023-08-04"), RFSTDTC = rep("2023-08-02", 4) ) calc_DY(df, DY_col = "XXDY", DTC_col = "DTC")
df <- data.frame( DTC = c("2023-08-01", "2023-08-02", "2023-08-03", "2023-08-04"), RFSTDTC = rep("2023-08-02", 4) ) calc_DY(df, DY_col = "XXDY", DTC_col = "DTC")
Wraps knitr::purl()
to create an .R script from a .Rmd file. It can also
auto-archive the .Rmd file to a [dir]/archive
sub-directory. This is useful
for turning first-attempt exploratory data analysis into production scripts
once the validation code is complete.
convert_to_script(filename, dir = NULL, archive = FALSE)
convert_to_script(filename, dir = NULL, archive = FALSE)
filename |
string, the file name of both the .Rmd file that will be read and the file name of the .R file to be written (do not include .Rmd or .R extension) |
dir |
string, the directory where the .Rmd file is and the .R file will
be written, default is |
archive |
logical, whether to auto-archive the .Rmd file; default is
|
The resulting script will take the same name as the .Rmd file but with a different extension (.R)
If [dir]/archive
does not already exist, it will be created
nothing
# get test notebook from the sdtmval/inst/extdata dir and copy it to temp dir test_file_dir <- system.file("extdata", package = "sdtmval") filename <- "test_notebook" temp_path <- tempdir() file.copy(from = file.path(test_file_dir, paste0(filename, ".Rmd")), to = file.path(temp_path, paste0(filename, ".Rmd"))) # create the script and archive the .Rmd file convert_to_script(dir = temp_path, filename = filename, archive = TRUE)
# get test notebook from the sdtmval/inst/extdata dir and copy it to temp dir test_file_dir <- system.file("extdata", package = "sdtmval") filename <- "test_notebook" temp_path <- tempdir() file.copy(from = file.path(test_file_dir, paste0(filename, ".Rmd")), to = file.path(temp_path, paste0(filename, ".Rmd"))) # create the script and archive the .Rmd file convert_to_script(dir = temp_path, filename = filename, archive = TRUE)
Utilizes the BLFL method from the SDTM spec to create a baseline flag: Equal
to "Y" for last record with non-missing –ORRES on or before first dose date
(RFSTDTC); NA
otherwise.
create_BLFL( tbl, sort_date, domain, grouping_vars = "USUBJID", RFSTDTC = "RFSTDTC", compare_date_method = "on or before" )
create_BLFL( tbl, sort_date, domain, grouping_vars = "USUBJID", RFSTDTC = "RFSTDTC", compare_date_method = "on or before" )
tbl |
a data frame with the variables |
sort_date |
a string, the column name by which to sort records within
each |
domain |
a string, the SDTM domain abbreviation |
grouping_vars |
a character vector of columns to group by when assigning
the BLFL, default is |
RFSTDTC |
a string, the column to use for |
compare_date_method |
a string, one of |
a modified copy of tbl
with the new column [domain]BLFL
df <- dplyr::tibble( USUBJID = c( rep(1, 3), rep(2, 3) ), XXORRES = c( 1, 2, 2, 1, 2, NA ), XXDTC = as.Date(c( "2017-02-05", "2017-02-06", "2017-02-07", "2017-02-05", "2017-02-06", "2017-02-07" )), RFSTDTC = as.Date(c( rep("2017-02-05", 3), rep("2017-02-07", 3) )) ) create_BLFL(df, sort_date = "XXDTC", domain = "XX")
df <- dplyr::tibble( USUBJID = c( rep(1, 3), rep(2, 3) ), XXORRES = c( 1, 2, 2, 1, 2, NA ), XXDTC = as.Date(c( "2017-02-05", "2017-02-06", "2017-02-07", "2017-02-05", "2017-02-06", "2017-02-07" )), RFSTDTC = as.Date(c( rep("2017-02-05", 3), rep("2017-02-07", 3) )) ) create_BLFL(df, sort_date = "XXDTC", domain = "XX")
Utilizes the EPOCH method from the SDTM spec: Missing when --DTC
is blank;
equal to 'SCREENING'
if --DTC
if before RFXSTDTC
; equal to 'TREATMENT'
if --DTC
is on or after RFXSTDTC
and on or before RFXENDTC
; equal to
'FOLLOW-UP'
if --DTC
is after RFXENDTC
.
create_EPOCH(tbl, date_col, RFXSTDTC = "RFXSTDTC", RFXENDTC = "RFXENDTC")
create_EPOCH(tbl, date_col, RFXSTDTC = "RFXSTDTC", RFXENDTC = "RFXENDTC")
tbl |
a data frame with date class columns |
date_col |
a string, the column name of the event date used to determine the EPOCH; this column can either have a date class or a character class in the YYYY-MM-DD format |
RFXSTDTC |
a string, the date column to use for |
RFXENDTC |
a string, the date column to use for |
a modified copy of tbl
with the EPOCH
column
df <- data.frame( DTC = c("2023-08-01", "2023-08-02", "2023-08-03", "2023-08-04"), RFXSTDTC = rep("2023-08-02", 4), RFXENDTC = rep("2023-08-03", 4) ) create_EPOCH(df, date_col = "DTC")
df <- data.frame( DTC = c("2023-08-01", "2023-08-02", "2023-08-03", "2023-08-04"), RFXSTDTC = rep("2023-08-02", 4), RFXENDTC = rep("2023-08-03", 4) ) create_EPOCH(df, date_col = "DTC")
Creates a –STAT variable and, if all measurements for a visit were not done, also changes all –TESTCD values as "–ALL"
create_STAT( df, domain, nd_ind, nd_ind_cd = "Yes", USUBJID = "USUBJID", VISIT = "VISIT" )
create_STAT( df, domain, nd_ind, nd_ind_cd = "Yes", USUBJID = "USUBJID", VISIT = "VISIT" )
df |
a data frame to modify |
domain |
a string, the domain abbreviation in all caps |
nd_ind |
a string, the variable name in |
nd_ind_cd |
a string, the code from the |
USUBJID |
a string, the variable name in |
VISIT |
a string, the variable name in |
a modified copy of df
df <- dplyr::tibble( USUBJID = paste("Subject", c(rep("A", 2), rep("B", 4), rep("C", 2))), VISIT = paste("Visit", c(1 , 2 , 1 , 1 , 2 , 2 , 2 , 2)), XXTESTCD = paste("Test", c(1 , 2 , 1 , 2 , 1 , 2 , 1 , 2)), ND = c("N", "N", "Y", "Y", "N", "N", "Y", "Y") ) create_STAT(df = df, domain = "XX", nd_ind = "ND", nd_ind_cd = "Y")
df <- dplyr::tibble( USUBJID = paste("Subject", c(rep("A", 2), rep("B", 4), rep("C", 2))), VISIT = paste("Visit", c(1 , 2 , 1 , 1 , 2 , 2 , 2 , 2)), XXTESTCD = paste("Test", c(1 , 2 , 1 , 2 , 1 , 2 , 1 , 2)), ND = c("N", "N", "Y", "Y", "N", "N", "Y", "Y") ) create_STAT(df = df, domain = "XX", nd_ind = "ND", nd_ind_cd = "Y")
This is an example data set to simulate a SDTM production domain 'DM' which
contains study start and end date information by subject. This can be used to
test create_BLFL()
, create_EPOCH()
, and calc_DY()
.
dm
dm
A data frame with 2 rows and 4 columns:
Subject identifier
Study start date
First exposure date
Last exposure date
This is an example data set to simulate raw EDC data from the fake form/table 'XX'.
edc_xx
edc_xx
A data frame with 8 rows and 6 columns:
Study identifier
Subject identifier
Visit name
Test name, coded
Test result
Converts all date columns to character class and replaces all NA
values in
character/date columns with ""
.
format_chars_and_dates(tbl)
format_chars_and_dates(tbl)
tbl |
a data frame, the SDTM table |
This function should be applied as one of the last steps in the data process
but before assign_meta_data()
.
a modified copy of the tbl
data frame
df <- data.frame( dates = as.Date(c("2017-02-05", NA)), strings = c(NA_character_, "this"), nums = c(1, NA) ) format_chars_and_dates(df)
df <- data.frame( dates = as.Date(c("2017-02-05", NA)), strings = c(NA_character_, "this"), nums = c(1, NA) ) format_chars_and_dates(df)
Reads-in the "Codelists"
sheet from the study's specification MS Excel file
and then filters that code list by the variables in the domain
get_codelist( domain, dir, filename, var_col = "Variable", codelist_sheet = "Codelists", varid_col = "ID" )
get_codelist( domain, dir, filename, var_col = "Variable", codelist_sheet = "Codelists", varid_col = "ID" )
domain |
string, SDTM domain or supplemental domain code |
dir |
string, specification directory |
filename |
string, file name of the specification |
var_col |
a string, the column name in the domain spec sheet that
contains the variables for that domain, default is |
codelist_sheet |
a string, the sheet name of the spec's code list from
the spec's .xlsx file, default is |
varid_col |
a string, the column name in the |
a data frame with the code list
get_data_spec()
, get_key_vars()
, assign_meta_data()
work_dir <- system.file("extdata", package = "sdtmval") codelists <- get_codelist(domain = 'XX', dir = work_dir, filename = "spec.xlsx")
work_dir <- system.file("extdata", package = "sdtmval") codelists <- get_codelist(domain = 'XX', dir = work_dir, filename = "spec.xlsx")
Reads the specified domain variable specification sheet from an MS Excel file.
get_data_spec(domain, dir, filename, arrange_by = "Order")
get_data_spec(domain, dir, filename, arrange_by = "Order")
domain |
string, SDTM domain or supplemental domain code |
dir |
string, specification directory |
filename |
string, file name of the specification |
arrange_by |
character vector, the column(s) by which to sort the domain
sheet, default is |
The readxl::read_excel()
function will causes an access denied warning when
reading in a read-only specification file. This does not affect the data
import. Variables will be arranged in descending order per the "Order"
column in the specification.
a data frame of the variable specification for domain
get_key_vars()
, get_codelist()
, assign_meta_data()
work_dir <- system.file("extdata", package = "sdtmval") spec <- get_data_spec(domain = "XX", dir = work_dir, filename = "spec.xlsx")
work_dir <- system.file("extdata", package = "sdtmval") spec <- get_data_spec(domain = "XX", dir = work_dir, filename = "spec.xlsx")
Reads the "Key Variables"
column from the SDTM specification MS Excel
file's "Datasets"
sheet for the specified domain
.
get_key_vars( domain, dir, filename, datasets_sheet = "Datasets", dataset_col = "Dataset", keyvar_col = "Key Variables" )
get_key_vars( domain, dir, filename, datasets_sheet = "Datasets", dataset_col = "Dataset", keyvar_col = "Key Variables" )
domain |
string, SDTM domain or supplemental domain code |
dir |
string, specification directory |
filename |
string, file name of the specification |
datasets_sheet |
a string, the sheet name in the specification Excel
file that has the key variables, default is |
dataset_col |
a string, the column name of the domains in the table in
|
keyvar_col |
a string, the column name of the key variables in the table
in |
The readxl::read_excel()
function will causes an access denied warning when
reading in a read-only specification file. This does not affect the data
import.
a character vector of key variables for the specified domain
get_data_spec()
, get_codelist()
, assign_meta_data()
work_dir <- system.file("extdata", package = "sdtmval") key_vars <- get_key_vars(domain = "XX", dir = work_dir, filename = "spec.xlsx")
work_dir <- system.file("extdata", package = "sdtmval") key_vars <- get_key_vars(domain = "XX", dir = work_dir, filename = "spec.xlsx")
Imputes missing date elements for start or end dates. Partial dates should be
in the format "UNKN-UN-UN"
or some combination of those characters and
numbers (ie "2017-UN-UN"
). Dates with no information or dates with a
missing year will be converted to NA
. For start dates, missing days are
assumed to be the first of the month while missing months are assumed to be
January. For end dates, missing days are assumed to be the last day of the
month and missing months are assumed to be December.
impute_pdates(dates, ptype, input_sep = "-")
impute_pdates(dates, ptype, input_sep = "-")
dates |
a character vector of partial dates (which could also contain full dates) in the format YYYY-MM-DD |
ptype |
a string of either |
input_sep |
the character that separates date components in |
a date vector of imputed dates in the format YYYY-MM-DD
reshape_adates()
, reshape_pdates()
, trim_dates()
,
vignette("Dates")
dates <- c( "UNKN-UN-UN", "2017-UN-UN", "2017-02-UN", "2017-UN-05", "2017-09-03", "UNKN-07-14", NA ) impute_pdates(dates, ptype = "start") impute_pdates(dates, ptype = "end")
dates <- c( "UNKN-UN-UN", "2017-UN-UN", "2017-02-UN", "2017-UN-05", "2017-09-03", "UNKN-07-14", NA ) impute_pdates(dates, ptype = "start") impute_pdates(dates, ptype = "end")
Reads-in EDC data table .csv files and puts them in a list.
read_edc_tbls(edc_tbls, dir)
read_edc_tbls(edc_tbls, dir)
edc_tbls |
character vector of EDC table file names (without extension) |
dir |
string, EDC data directory |
The file encoding will be UTF-8.
a named list of data frames where the names are taken from edc_tbls
and the data frames are the EDC data tables
edc_tbls <- c("xx", "vd") edc_dir <- system.file("extdata", package = "sdtmval") edc_dat <- read_edc_tbls(edc_tbls, dir = edc_dir)
edc_tbls <- c("xx", "vd") edc_dir <- system.file("extdata", package = "sdtmval") edc_dat <- read_edc_tbls(edc_tbls, dir = edc_dir)
Reads-in SDTM data tables store as .sas7bdat files and puts them in a list.
read_sdtm_tbls(sdtm_tbls, dir)
read_sdtm_tbls(sdtm_tbls, dir)
sdtm_tbls |
character vector of SDTM table file names (without extension) |
dir |
string, the directory containing the production SDTM tables |
The file encoding will be UTF-8.
a named list of data frames where the names are taken from
sdtm_tbls
and the data frames are the SDTM data
sdtm_tbls <- "dm" sdtm_dir <- system.file("extdata", package = "sdtmval") sdtm_dat <- read_sdtm_tbls(sdtm_tbls, dir = sdtm_dir)
sdtm_tbls <- "dm" sdtm_dir <- system.file("extdata", package = "sdtmval") sdtm_dat <- read_sdtm_tbls(sdtm_tbls, dir = sdtm_dir)
Re-arranges full and partial dates in the general form of "MM/DD/YYYY"
to
the ISO 8601 format ("YYYY-MM-DD"
). This function is appropriate for
vectors with mixed full and partial dates because it will not convert the
partial dates to NA
which would occur if you used
as.Date("02/UN/2017", format = "%m/%d/%Y")
.
reshape_adates(dates)
reshape_adates(dates)
dates |
a character vector of full and/or partial dates |
The date component separator in the input vector dates
can be any
character.
a character vector of full and/or partial dates in the format
"YYYY-MM-DD"
reshape_pdates()
, impute_pdates()
, trim_dates()
,
vignette("Dates")
dates <- c("02/05/2017", "UN/UN/2017", "02-05-2017", NA) reshape_adates(dates)
dates <- c("02/05/2017", "UN/UN/2017", "02-05-2017", NA) reshape_adates(dates)
Re-arranges partial dates from a format of "UN-UNK-UNKN"
("DD-MMM-YYYY"
)
to "UN/UN/UNKN"
("MM/DD/YYYY"
).
reshape_pdates(dates, output_sep = "/")
reshape_pdates(dates, output_sep = "/")
dates |
a character vector of partial dates |
output_sep |
the date component separator for the output, default is
|
The separator character between dates components for the input vector
dates
can be any commonly used date separator ("/"
, "-"
, "."
,
" "
).
In the starting format, the month ("UNK"
) is a three letter abbreviation
but, in the output format, the month is converted to a number
The output format is a character vector, not a Date vector, to make some common SDTM date workflow operations easier
The case of the input month abbreviation does not matter; "Feb"
,
"feb"
, and "FEB"
will yield the same results
a character vector of partial dates in the format "UN/UN/UNKN"
("MM/DD/YYYY"
)
reshape_adates()
, impute_pdates()
, trim_dates()
,
vignette("Dates")
dates <- c( "UN-UNK-UNKN", "UN/UNK/UNKN", "UN-UNK-2017", "UN-Feb-2017", "05-Feb-2017", "05-UNK-2017", "05-Feb-UNKN", NA ) reshape_pdates(dates)
dates <- c( "UN-UNK-UNKN", "UN/UNK/UNKN", "UN-UNK-2017", "UN-Feb-2017", "05-Feb-2017", "05-UNK-2017", "05-Feb-UNKN", NA ) reshape_pdates(dates)
This table simulates an excerpt from a SDTM specification .xlsx file for the
'Codelists' tab which provides coded and decoded values from XXTESTCD
and
XXTEST
variables, respectively. This data set can be used to test the
get_codelist()
function.
spec_codelists
spec_codelists
A data frame with 3 rows and 3 columns:
The variable identifier/name
The coded term
The corresponding decoded value for the coded term
This table simulates an excerpt from a SDTM specification .xlsx file for the
'Datasets' tab which provides the key variables for the fake domain XX. This
data set can be used to test the get_key_vars()
function.
spec_datasets
spec_datasets
A data frame with 1 row and 4 columns:
The domain
The domain description
Defines what qualifies as a unique record
The domain's key variables
This table simulates an excerpt from a SDTM specification .xlsx file for the
fake domain tab XX which provides the labels, data types, and lengths by
variable. This data set can be used to test the get_data_spec()
and assign_meta_data()
functions.
spec_XX
spec_XX
A data frame with 12 rows and 5 columns:
The order of the varibles in the data set
The domain abbreviation
The domain's variables
Variable labels
Variable data types
The maximum allowed length of an entry
Trims the white space on both sides of strings in a character vector and
replaces blank values (""
and " "
) with NA
for all columns in a data
frame that have a character class.
trim_and_make_blanks_NA(tbl)
trim_and_make_blanks_NA(tbl)
tbl |
a data frame, the SDTM table |
This function should be applied as one of the first steps in the data process to ensure consistent handling of all strings.
a modified copy of the tbl
data frame
df <- data.frame(one = c(" a", "", " ")) trim_and_make_blanks_NA(df)
df <- data.frame(one = c(" a", "", " ")) trim_and_make_blanks_NA(df)
Removes unknown elements from a partial date. For example, "2017-UN-UN"
is trimmed to "2017"
and "2017-05-UN"
is trimmed to "2017-05"
.
Values of "UNKN-UN-UN"
are converted to NA
. Values where only
the year and day are known are converted to just the year, ie "2017-UN-01"
converts to "2017"
. Full dates are not modified.
trim_dates(dates, input_sep = "-")
trim_dates(dates, input_sep = "-")
dates |
a character vector of partial dates in the format |
input_sep |
the character that separates date components in the input
vector |
a character vector of trimmed partial dates and full dates
reshape_adates()
, reshape_pdates()
, impute_pdates()
,
vignette("Dates")
dates <- c( "UNKN-UN-UN", "2017-UN-UN", "2017-02-UN", "2017-UN-05", "2017-09-03", "UNKN-07-14", NA ) trim_dates(dates)
dates <- c( "UNKN-UN-UN", "2017-UN-UN", "2017-02-UN", "2017-UN-05", "2017-09-03", "UNKN-07-14", NA ) trim_dates(dates)
This is an example data set to simulate raw EDC data from the 'VD' form/table which contains visit date information by subject.
vd
vd
A data frame with 6 rows and 3 columns:
Subject identifier
Visit name
Visit date
Writes a .txt file of the output from utils::sessionInfo()
with the file
name [filename]_sessionInfo.txt
. By creating a log of the R session
conditions a script was run with, results from the script can be reproduced
in the future.
write_sessionInfo(filename, dir = NULL)
write_sessionInfo(filename, dir = NULL)
filename |
a string, the script file name (with or without .R extension) |
dir |
a string, the directory to write to, default is |
nothing
path <- tempdir() write_sessionInfo(filename = "test.R", dir = path)
path <- tempdir() write_sessionInfo(filename = "test.R", dir = path)
Writes a data frame to a SAS transport file (.xpt) named like "[domain].xpt"
write_tbl_to_xpt(tbl, filename, dir = NULL, label = NULL)
write_tbl_to_xpt(tbl, filename, dir = NULL, label = NULL)
tbl |
a data frame to write |
filename |
a string, the SDTM domain or supplemental domain name which will become the file name and the name attribute of the transport file, the .xpt file extension is optional |
dir |
a string, the directory to write to, default is |
label |
a string, the data set name/label for the |
Files will be written using version 5 .xpt files
nothing
tbl <- dplyr::tibble(one = as.numeric(1:3), two = letters[1:3]) path <- tempdir() write_tbl_to_xpt(tbl, filename = "test.xpt", dir = path)
tbl <- dplyr::tibble(one = as.numeric(1:3), two = letters[1:3]) path <- tempdir() write_tbl_to_xpt(tbl, filename = "test.xpt", dir = path)
This data set is used to test the assign_meta_data()
function and contains
a fake SDTM domain XX but without label or lengths assigned to the column
attributes.
xx_no_meta_data
xx_no_meta_data
A data frame with 10 rows and 11 columns:
Study identifier
Subject identifier
Sequence number
Coded test name
Test name
Measurement in original units
Baseline flag
Visit name
EPOCH
Measurement date
Measurement day of study