The front door. masque() walks the whole procedure - read the data,
propose column roles, (in an interactive session) pause for you to
review the plan, mask, audit, and optionally write the result - from a
single call. It dispatches on the input: a single file or data frame
goes through mask(); a folder, an Excel workbook, or a named list of
tables goes through mask_set().
Usage
masque(
input,
roles = NULL,
out = NULL,
mode = c("local", "collaborate"),
seed = NULL,
clean = c("auto", "report", "off"),
alias_names = FALSE,
conditional = FALSE,
ask = interactive(),
overwrite = FALSE,
quiet = FALSE,
allow_high = FALSE
)Arguments
- input
A data frame, a single tabular file (
.csv/.tsv/.fst), a folder of such files, an Excel workbook, or a named list of data frames.- roles
Optional. A roles table (single-table input) or named list of roles tables (set input). When supplied, the interactive review is skipped.
- out
Optional output path. For a single table, a
.csvfile (or.xlsxwithwritexl). For a set, a folder (one CSV per table) or an.xlsxworkbook. WhenNULL(default) nothing is written.- mode
Either
"local"(default) or"collaborate".- seed
Optional integer for reproducibility.
- clean
Hygiene mode passed to
clean_table()("auto","report","off").- alias_names
Hide column names; see
mask()/mask_set().- conditional
Logical scalar (default
FALSE). The conditional clone mode passed through tomask()/mask_set(): whenTRUE, numeric columns are re-simulated within each treatment-by-design stratum so the treatment-to-outcome relationship survives the clone. Seemask()for the full account.- ask
Whether to pause for interactive review when
rolesis not supplied. Defaults tointeractive(). SetFALSEto proceed with the proposed plan without prompting.- overwrite
Passed to the writer when
outis set.- quiet
Suppress progress messages. Warnings - including the HIGH-leakage finding - are never suppressed.
- allow_high
Logical (default
FALSE). Whenoutis set and the collaborate-mode audit flagged HIGH leakage, the write is refused. PassTRUEto write anyway after your own review; the override raises amasque_high_overridewarning and is recorded in the recipe's warnings, so the exception stays auditable.
Value
A masque object (single-table input) or a masque_set
object (set input), invisibly. Use synthetic() and recipe().
Details
It is also fully scriptable. Pass an edited roles table (or named
list of them) to skip the interactive review, and an out path to
write the masked result in one go. The returned object is the same
masque / masque_set you would get from the lower-level verbs, so
anything you can do with those you can do with the result here.
The guided flow
Read the input into one or more clean rectangular tables.
Propose roles for every column (skipped if you pass
roles).Review - in an interactive session with no
rolessupplied, the proposed plan is printed and you are asked to proceed, edit, or stop. Editing opens the roles table in the spreadsheet editor (utils::edit()) where the platform provides one; when it cannot start (for example macOS without XQuartz, or a headless session), a console editor takes over - pick a column, then a role and an action from numbered menus, with every change applied throughset_role()so default actions re-resolve exactly as on the scriptable path. Withask = FALSE(the default in non-interactive use) the proposed plan is used as-is, with a note.Mask the data in the chosen
mode.Audit - in
collaboratemode the leakage audit runs and its headline is printed. A HIGH finding surfaces as a classed warning (masque_high_leakage) - it is never silenced by the guided flow.Write - if
outis set, the masked data is written there (mirroring the input format), unless the audit left unresolved HIGH findings: then the write is refused (nothing is written) and the flagged columns are listed. Resolve them and mask again, or passallow_high = TRUEafter your own review - the override is warned (masque_high_override) and recorded on the recipe. The private recipe is never written automatically; persist it yourself withsave_recipe().
Examples
# Scripted single-table use (no prompt because roles are supplied):
r <- propose_roles(iris)
r <- set_role(r, "Sepal.Length", role = "outcome")
m <- masque(iris, roles = r, seed = 1, ask = FALSE, quiet = TRUE)
head(synthetic(m))
#> # A tibble: 6 × 5
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> <dbl> <dbl> <dbl> <dbl> <fct>
#> 1 5.1 3.2 4 1.5 setosa
#> 2 6 3 3.7 0.4 setosa
#> 3 5 3 4.6 1.1 setosa
#> 4 7.2 2.6 5.8 1.7 setosa
#> 5 6.1 2.4 5.8 1.5 setosa
#> 6 5 2.7 4.5 1.4 setosa