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

write_secuTrial(object, ...)

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

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

Arguments

object

secuTrialdata object

...

further parameters

format

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

metadata

if TRUE then metadate files will also be written

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 _f (rather than _factor). Further variable names may be altered in the conversion process. For details please refer to the haven documentation.

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)
#> Read export successfully.
#> The following export options deviate from the suggested specifications:
#> Data from hidden fields is part of the export.
#> Short names was not selected.
tdir <- tempdir()
write_secuTrial(sT_export, format = "dta", path = tdir)
#> [[1]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atmiv.dta"
#> 
#> [[2]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/ctu05baseline.dta"
#> 
#> [[3]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atmnpctu05baseline.dta"
#> 
#> [[4]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/ctu05outcome.dta"
#> 
#> [[5]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atmnpctu05outcome.dta"
#> 
#> [[6]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/ctu05treatment.dta"
#> 
#> [[7]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atmnpctu05treatment.dta"
#> 
#> [[8]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/ctu05allmedi.dta"
#> 
#> [[9]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atmnpctu05allmedi.dta"
#> 
#> [[10]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/ctu05studyterminat.dta"
#> 
#> [[11]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atmnpctu05studyterminat.dta"
#> 
#> [[12]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/ctu05ae.dta"
#> 
#> [[13]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atmnpctu05ae.dta"
#> 
#> [[14]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/ctu05sae.dta"
#> 
#> [[15]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atmnpctu05sae.dta"
#> 
#> [[16]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/emnpctu05surgeries.dta"
#> 
#> [[17]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atemnpctu05surgeries.dta"
#> 
#> [[18]]
#> [1] "Saved to /var/folders/lr/439_fwvd3m76p9vy50d57kcc0000gn/T//RtmpvseisZ/atadverseevents.dta"
#> 
list.files(tdir)
#>  [1] "atadverseevents.dta"         "atemnpctu05surgeries.dta"   
#>  [3] "atmiv.dta"                   "atmnpctu05ae.dta"           
#>  [5] "atmnpctu05allmedi.dta"       "atmnpctu05baseline.dta"     
#>  [7] "atmnpctu05outcome.dta"       "atmnpctu05sae.dta"          
#>  [9] "atmnpctu05studyterminat.dta" "atmnpctu05treatment.dta"    
#> [11] "ctu05ae.dta"                 "ctu05allmedi.dta"           
#> [13] "ctu05baseline.dta"           "ctu05outcome.dta"           
#> [15] "ctu05sae.dta"                "ctu05studyterminat.dta"     
#> [17] "ctu05treatment.dta"          "downlit"                    
#> [19] "emnpctu05surgeries.dta"      "file1ae617856065"           
#> [21] "file1ae61d802447"            "file1ae6357b92f3"           
#> [23] "file1ae64bfe1a9d"            "file1ae666cb5a5b"           
#> [25] "file1ae669638da9"