View source: R/SuppressKDisclosure.R
SuppressKDisclosure | R Documentation |
A function for suppressing frequency tables using the k-disclosure method.
SuppressKDisclosure(
data,
coalition = 0,
mc_hierarchies = NULL,
upper_bound = Inf,
dimVar = NULL,
formula = NULL,
hierarchies = NULL,
freqVar = NULL,
...,
spec = PackageSpecs("kDisclosureSpec")
)
data |
a data.frame representing the data set |
coalition |
numeric vector of length one, representing possible size of an attacking coalition. This parameter corresponds to the parameter k in the definition of k-disclosure. |
mc_hierarchies |
a hierarchy representing meaningful combinations to be
protected. Default value is |
upper_bound |
numeric value representing minimum count considered safe.
Default set to |
dimVar |
The main dimensional variables and additional aggregating variables. This parameter can be useful when hierarchies and formula are unspecified. |
formula |
A model formula |
hierarchies |
List of hierarchies, which can be converted by
|
freqVar |
name of the frequency variable in |
... |
parameters passed to children functions |
spec |
|
A data.frame containing the publishable data set, with a boolean
variable $suppressed
representing cell suppressions.
Daniel P. Lupp
# data
data <- SSBtools::SSBtoolsData("mun_accidents")
# hierarchies as DimLists
mun <- data.frame(levels = c("@", rep("@@", 6)),
codes = c("Total", paste("k", 1:6, sep = "")))
inj <- data.frame(levels = c("@", "@@" ,"@@", "@@", "@@"),
codes = c("Total", "serious", "light", "none", "unknown"))
dimlists <- list(mun = mun, inj = inj)
inj2 <- data.frame(levels = c("@", "@@", "@@@" ,"@@@", "@@", "@@"),
codes = c("Total", "injured", "serious", "light", "none", "unknown"))
inj3 <- data.frame(levels = c("@", "@@", "@@" ,"@@", "@@"),
codes = c( "shadowtotal", "serious", "light", "none", "unknown"))
mc_dimlist <- list(inj = inj2)
mc_nomargs <- list(inj = inj3)
#' # Example with formula, no meaningful combination
out <- SuppressKDisclosure(data, coalition = 1, freqVar = "freq", formula = ~mun*inj)
# Example with hierarchy and meaningful combination
out2 <- SuppressKDisclosure(data, coalition = 1, freqVar = "freq",
hierarchies = dimlists, mc_hierarchies = mc_dimlist)
#' # Example of table without mariginals, and mc_hierarchies to protect
out3 <- SuppressKDisclosure(data, coalition = 1, freqVar = "freq",
formula = ~mun:inj, mc_hierarchies = mc_nomargs )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.