# export
library("datasets")
export(mtcars, csv_file <- tempfile(fileext = ".csv")) # comma-separated values
export(mtcars, rds_file <- tempfile(fileext = ".rds")) # R serialized
export(mtcars, sav_file <- tempfile(fileext = ".sav")) # SPSS
# import
x <- import(csv_file)
y <- import(rds_file)
z <- import(sav_file)
# convert sav (SPSS) to dta (Stata)
convert(sav_file, dta_file <- tempfile(fileext = ".dta"))
# cleanup
unlink(c(csv_file, rds_file, sav_file, dta_file))
Run the code above in your browser using DataLab