write_synthetic: Write a synthetic table (or workbook) in the format of its...

View source: R/write_output.r

write_syntheticR Documentation

Write a synthetic table (or workbook) in the format of its source

Description

Excel output keeps the original header (duplicate names included), the sheet names and order and, column by column, the cell type readxl saw in the source (numbers as numbers, dates as dates, everything else as text). Formulas, formatting and merged cells are not reproduced (values only). .xls sources are written as .xlsx. CSV output writes the raw strings with the original header and delimiter, in UTF-8.

Usage

write_synthetic(res, path)

Arguments

res

A synth_result, or a list of them (one per sheet, in order) for a workbook. Results passed through with "drop" are left out.

path

Output path.

Value

path, invisibly.

Examples

df <- data.frame(id = sprintf("AB%03d", 1:60), value = 1:60,
                 code = rep(c(0, 1, NA), 20))
path <- file.path(tempdir(), "write_synthetic_source.csv")
utils::write.csv(df, path, row.names = FALSE, na = "")
src <- read_source(path)
res <- synthesize_table(src, n_folds = 2, seed = 1, verbose = FALSE)
out_path <- file.path(tempdir(), "write_synthetic_output.csv")
write_synthetic(res, out_path)
file.exists(out_path)

cellsynth documentation built on Oct. 31, 2026, 1:07 a.m.