dims <- list(
v1 = sdcHierarchies::hier_create("tot", letters[1:4]),
v2 = sdcHierarchies::hier_create("tot", letters[5:8])
)
N <- 150
df <- data.frame(
v1 = sample(letters[1:4], N, replace = TRUE),
v2 = sample(letters[5:8], N, replace = TRUE)
)
sdc <- makeProblem(data = df, dimList = dims)
# set primary suppressions
specs <- data.frame(
v1 = c("a", "b", "a"),
v2 = c("e", "e", "f")
)
sdc <- change_cellstatus(sdc, specs = specs, rule = "u")
# attack all primary sensitive cells
# the cells can be recomputed exactly
attack(sdc, to_attack = NULL)
# protect the table and attack again
sdc <- protectTable(sdc, method = "SIMPLEHEURISTIC")
attack(sdc, to_attack = NULL)
# attack only selected cells
attack(sdc, to_attack = c(7, 12))
Run the code above in your browser using DataLab