# load micro data
utils::data("microdata1", package = "sdcTable")
# load problem (as it was created in the example in ?makeProblem
p <- sdc_testproblem(with_supps = FALSE)
# we have a look at the frequency table by gender and region
xtabs(rep(1, nrow(microdata1)) ~ gender + region, data = microdata1)
# 2 units contribute to cell with region=='A' and gender=='female'
# --> this cell is considered sensitive according the the
# freq-rule with 'maxN' equal to 2!
p1 <- primarySuppression(
object = p,
type = "freq",
maxN = 2
)
# we can also apply a p-percent rule with parameter "p" being 30 as below.
# This is only possible if we are dealing with micro data and we also
# have to specify the name of a numeric variable.
p2 <- primarySuppression(
object = p,
type = "p",
p = 30,
numVarName = "val"
)
# looking at anonymization states we see, that one cell is primary
# suppressed (sdcStatus == "u")
# the remaining cells are possible candidates for secondary cell
# suppression (sdcStatus == "s") given the frequency rule with
# parameter "maxN = 2".
#
# Applying the p-percent rule with parameter 'p = 30' resulted in
# two primary suppressions.
data.frame(
p1_sdc = getInfo(p1, type = "sdcStatus"),
p2_sdc = getInfo(p2, type = "sdcStatus")
)
Run the code above in your browser using DataLab