This function is a wrapper for a variety of write functions that also checks whether the data set has been cleared for writing based on the DUA level restrictions chosen by the user. If restricted variables remain in the data set, the function will return an error and will not write the data set.

  output_type = c("rds", "rdata", "csv", "tsv", "delimited", "stata", "sas", "spss"),



Data frame object to save.


Name and path for saved file, with or without file type ending.


Output data file type; options include rds (DEFAULT), rdata, csv, tsv, delimited, stata, sas, and spss.


Arguments to pass to write function based on the selected output_type; see details for more information.


The following output types are supported (with the underlying write function and default arguments accompanying):

All arguments for these internal write functions, including those with default values, can be modified by adding them to the top-level write_dua_df() function.


## -------------- ## Setup ## -------------- ## set DUA crosswalk dua_cw <- system.file('extdata', 'dua_cw.csv', package = 'duawranglr') set_dua_cw(dua_cw)
#> -- duawranglr note ------------------------------------------------------------- #> DUA crosswalk has been set!
## read in data admin <- system.file('extdata', 'admin_data.csv', package = 'duawranglr') df <- read_dua_file(admin) ## set restriction level set_dua_level('level_iii') ## remove restrictive variables df <- dplyr::select(df, -c(sid,sname,tname)) ## -------------- ## check restrictions check_dua_restrictions(df)
#> -- duawranglr note ------------------------------------------------------------- #> Data set has passed check and may be saved.
## able to write since restrictions check passed file <- file.path(tempdir(), 'clean_data.csv') write_dua_df(df, file_name = file, output_type = 'csv') if (FALSE) { write_dua_df(df, 'clean_data', output_type = 'delimited', sep = '|') write_dua_df(df, 'clean_data', output_type = 'stata', version = 11) }