Writes a reviewable export bundle containing the synthetic data, a human guide, an optional comparison report, a combined agent recipe, the packaged agent instructions, and a manifest. By default the bundle is written as a zip archive.
Usage
export_synthetic(
synthetic,
original = NULL,
comparison = NULL,
privacy = NULL,
path,
format = c("zip", "dir"),
sanitize_for_spreadsheets = TRUE,
purpose = NULL,
roles = NULL,
include_original_names = NULL,
fail_on_exact_match = FALSE,
include_report = TRUE,
include_dictionary = TRUE,
code_readiness = NULL,
compact = FALSE,
overwrite = FALSE
)Arguments
- synthetic
A synthetic data frame, typically from
synthesize_data().- original
Optional original data frame. When provided, used for the data dictionary, comparison fallback, privacy fallback, and exact-row guard.
- comparison
Optional
dataganger_comparisonobject. IfNULLandoriginalis supplied,compare_synthetic()is run automatically.- privacy
Optional
dataganger_privacy_checkobject. IfNULLandoriginalis supplied,privacy_check()is run automatically at the post stage.- path
Output path. Required. For
format = "zip", this is the archive path. Forformat = "dir", this is the output directory.- format
Character. One of
"zip"or"dir".- sanitize_for_spreadsheets
Logical. When
TRUE(the default), character-like cells beginning with=,+,-, or@after leading whitespace are prefixed with a single quote before CSV export.- purpose
Optional purpose label for README text. Defaults to the purpose recorded in
attr(synthetic, "spec")when available.- roles
Optional recorded role decisions as a
dataganger_rolesdata frame. When supplied, the export bundle includes the exact column decisions needed to reproduce the same synthetic output.- include_original_names
Logical or
NULL. Controls whether the human guide and manifest recipe preserve original variable names. WhenNULL, this defaults toTRUEunlessname_strategy = "dictionary_only", in which case it defaults toFALSE.- fail_on_exact_match
Logical. When
TRUE, abort export if exact-row matches are detected fornrow(original) >= 20. WhenFALSE(the default), exact-row matches are recorded in the privacy report and manifest, and a warning is emitted instead.- include_report
Logical. When
TRUE(the default), writehuman/comparison_report.html. Ifrmarkdown/knitrare unavailable, the report is skipped with a message instead of an error.- include_dictionary
Deprecated, ignored.
- code_readiness
Optional
dataganger_code_readinessobject fromcheck_code_readiness(). When supplied, writesagent/code_readiness_report.jsoninto the bundle.- compact
Deprecated, ignored.
- overwrite
Logical. When
FALSE(the default), existing output paths are refused.
Examples
dat <- data.frame(id = 1:50, grp = rep(letters[1:5], each = 10))
spec <- synth_spec(purpose = "demo", seed = 1)
syn <- synthesize_data(dat, spec)
if (FALSE) { # \dontrun{
export_synthetic(syn, original = dat, path = tempfile(fileext = ".zip"))
} # }
