Learn R Programming

secuTrialR (version 1.1.1)

write_secuTrial: 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 secuTrialdata write_secuTrial(object, format = "dta", metadata = FALSE, ...)

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

Value

a list of filenames

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.

Examples

Run this code
# 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)

Run the code above in your browser using DataLab