write_secuTrial: Write secuTrial exports to other formats

View source: R/write_secuTrial.R

write_secuTrialR Documentation

Write secuTrial exports to other formats

Description

Convert the export prepared in R and export it to SPSS (sav), Stata (dta) or SAS (sas, xpt version 8) using the haven package.

Usage

write_secuTrial(object, ...)

## S3 method for class 'secuTrialdata'
write_secuTrial(object, format = "dta", metadata = FALSE, ...)

## S3 method for class 'data.frame'
write_secuTrial(df, filename, path = "", format = "dta", ...)

Arguments

object

secuTrialdata object

...

further parameters

format

format in which to save the export (one of "dta", "sas", "sav", "xpt")

metadata

if TRUE then metadate files will also be written

df

a data.frame

filename

file name

path

directory where the files should be saved

Details

Due to variable naming limitations in other packages, date variables are appended with _d (rather than _date), datetime/POSIX variables are appended with _dt (rather than _datetime) and factors with _f (rather than _factor). Further variable names may be altered in the conversion process. For details please refer to the haven documentation.

Value

a list of filenames

Examples

# prepare path to example export
export_location <- system.file("extdata", "sT_exports", "lnames",
                               "s_export_CSV-xls_CTU05_long_ref_miss_en_utf8.zip",
                               package = "secuTrialR")
# load all export data
sT_export <- read_secuTrial(data_dir = export_location)
tdir <- tempdir()
write_secuTrial(sT_export, format = "dta", path = tdir)
list.files(tdir)


secuTrialR documentation built on March 7, 2023, 5:35 p.m.