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

write_tsExport(object, ...)

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

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

Arguments

object

tsExport 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

Value

a list of filenames

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 _cat (rather than _factor). Further variable names may be altered in the conversion process. For details please refer to the haven documentation. Since this has not been heavily tested or used there may be issues and you might prefer doing this manually with the haven package. One particular sticking point is the length of variable names - R is not restrictive in this respect, but other software can be. read_tsExport does not truncate names, prefering to leave this to the user, which can cause write_tsExport() to fail with an error.

References

Conversion to SPSS, STATA, SAS https://github.com/SwissClinicalTrialOrganisation/secuTrialR/blob/master/R/write_secuTrial.R https://cran.r-project.org/web/packages/secuTrialR/vignettes/secuTrialR-package-vignette.pdf

Examples

if (FALSE) { # \dontrun{
# read ts data
EXPORT_DIR <- file.path("/path/to/transferstelle_export",
                        "export_directory")
# load all export data
tsExport <- read_tsExport(EXPORT_DIR, separator = ",", decimal = ".")
tdir <- tempdir()
write_tsExport(tsExport, format = "sav", path = tdir)
list.files(tdir)
} # }