| mask | R Documentation |
Takes one data frame and a user-edited roles table (from
propose_roles(), possibly adjusted with set_role()) and produces
a synthetic clone according to each column's action. Returns a
masque S7 object holding the synthetic data and a private
masque_recipe.
mask(
df,
roles,
mode = c("local", "collaborate"),
seed = NULL,
clean = c("auto", "report", "off"),
alias_names = FALSE,
conditional = FALSE,
ladder = c("hierarchy", "levels"),
coords = NULL,
events = NULL,
grain = TRUE,
allow_unmasked_coords = FALSE,
allow_kept_outcome = FALSE,
quiet = FALSE,
.shared_maps = list(),
.cleaning = NULL,
...
)
df |
A data frame, or the |
roles |
A roles table from |
mode |
Either |
seed |
Optional integer for reproducibility. |
clean |
Label and column-name hygiene before masking, passed to
|
alias_names |
Hide the column names themselves. |
conditional |
Logical scalar (default The stratum is chosen by a coarsening ladder. Treatment crossed
with every retained design column is the finest rung, but on a
replicated factorial that rung holds one row per cell, which is too
thin to synthesise. The ladder then drops design columns, in the order
set by |
ladder |
How the coarsening ladder orders the design columns it may
drop, and what it keeps of a dropped one. |
coords |
Optional geographic-coordinate declaration. Supply one or more
latitude/longitude pairs and each is coarsened in place by an on-land
jitter (see |
events |
Optional linked time-to-event outcomes. One spec per group of
linked events, |
grain |
Single logical (default |
allow_unmasked_coords |
Single logical. A masked table must not carry
a real coordinate, so by default |
allow_kept_outcome |
Single logical. In collaborate mode an outcome
with the action |
quiet |
Single logical. |
.shared_maps |
Internal. A named list of pre-computed
|
.cleaning |
Internal. The cleaning record of a table |
... |
Must be empty. An unused argument, for example a misspelled name, is an error. |
mode = "local" marks the synthetic for owner development only; the
reminder is recorded on the recipe and shown when the object prints.
mode = "collaborate" additionally jitters re-simulated numerics
within their measurement resolution (stochastically rounding
integers) and runs audit_mask() automatically; a HIGH finding is
raised as a classed warning (masque_high_leakage) and blocks the
package-managed writers (masque()'s out, write_set()) until it
is resolved or explicitly overridden. Which columns are aliased,
kept, or dropped is decided by the action column of roles -
propose_roles() resolves mode-appropriate defaults, so the table
you reviewed is the plan that runs.
Collaborate mode changes the transformations and runs the audit. Whether a synthetic table is appropriate for a given collaborator, environment or jurisdiction is a release decision for the data custodian; masque informs that decision, it does not make it.
A masque S7 object. Use synthetic() and recipe() to
extract the components.
keepByte-identical pass-through, both modes.
scrambleNumeric outcome / covariate columns are re-simulated jointly via a Gaussian copula on the global Pearson covariance, with empirical-quantile marginals. Categorical, date, and text columns are row-permuted within non-NA positions, class preserved. Treatment columns get a seeded label permutation - the assignment structure never moves.
aliasAs scramble where applicable, plus opaque label
substitution: treatments become trt_NNN (<col>_trt_NNN when
two or more treatments are aliased. A numeric treatment becomes
text, and unmask() restores its exact values), categorical
covariates <col>_LNNN, design labels <col>_DNNN (in place -
structure intact), ids <col>_INNN (in place - row linkage
intact), text values <col>_TNNN. A key mask_set() shares across
tables becomes <col>_KNNN. NNN has at least three digits.
dropColumn excluded from the synthetic, both modes.
The NA mask of every retained column is preserved cell-by-cell. RNG state is preserved across the call.
propose_roles(), set_role(), roles_validate(),
synthetic(), recipe(), roles(), reveal_maps(), audit_mask(),
data_card().
r <- propose_roles(iris)
r <- set_role(r, "Sepal.Length", role = "outcome")
m <- mask(iris, r, seed = 1)
head(synthetic(m))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.