Description Usage Arguments Value Author(s) See Also Examples
protectLinkedTables
can be used to protect tables, that have
common cells. It is of course required that after the anonymization process
has finished, all common cells have the same anonymization state in both
tables.
1 | protectLinkedTables(objectA, objectB, commonCells, method, ...)
|
objectA |
a |
objectB |
a |
commonCells |
a list object defining common cells in
|
method |
a character vector of length 1 specifying the algorithm that should be used to protect the primary sensitive table cells. Allowed values are:
|
... |
additional arguments to control the secondary cell suppression algorithm. For details, see |
a list of length 2 with each list-element being an safeObj-class
object
Bernhard Meindl bernhard.meindl@statistik.gv.at
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | ## Not run:
# load micro data for further processing
sp <- searchpaths()
fn <- paste(sp[grep("sdcTable", sp)], "/data/microData2.RData", sep="")
microData <- get(load(fn))
# table1: defined by variables 'gender' and 'ecoOld'
microData1 <- microData[,c(2,3,5)]
# table2: defined by variables 'region', 'gender' and 'ecoNew'
microData2 <- microData[,c(1,2,4,5)]
# we need to create information on the hierarchies
# variable 'region': exists only in microDat2
d_region <- hier_create(root = "Tot", nodes = c("R1", "R2"))
# variable 'gender': exists in both datasets
d_gender <- hier_create(root = "Tot", nodes = c("m", "f"))
# variable 'eco1': exists only in microDat1
d_eco1 <- hier_create(root = "Tot", nodes = c("A", "B"))
d_eco1 <- hier_add(d_eco1, root = "A", nodes = c("Aa", "Ab"))
d_eco1 <- hier_add(d_eco1, root = "B", nodes = c("Ba", "Bb"))
# variable 'ecoNew': exists only in microDat2
d_eco2 <- hier_create(root = "Tot", nodes = c("C", "D"))
d_eco2 <- hier_add(d_eco2, root = "C", nodes = c("Ca", "Cb", "Cc"))
d_eco2 <- hier_add(d_eco2, root = "D", nodes = c("Da", "Db", "Dc"))
# creating objects holding information on dimensions
dl1 <- list(gender = d_gender, ecoOld = d_eco1)
dl2 <- list(region = d_region, gender = d_gender, ecoNew = d_eco2)
# creating input objects for further processing. For details have a look at
# \code{\link{makeProblem}}.
p1 <- makeProblem(
data = microData1,
dimList = dl1,
dimVarInd = 1:2,
numVarInd = 3
)
p2 <- makeProblem(
data = microData2,
dimList = dl2,
dimVarInd = 1:3,
numVarInd = 4
)
# the cell specified by gender == "Tot" and ecoOld == "A"
# is one of the common cells! -> we mark it as primary suppression
p1 <- changeCellStatus(
object = p1,
characteristics = c("Tot", "A"),
varNames = c("gender", "ecoOld"),
rule = "u",
verbose = FALSE
)
# the cell specified by region == "Tot" and gender == "f" and ecoNew == "C"
# is one of the common cells! -> we mark it as primary suppression
p2 <- changeCellStatus(
object = p2,
characteristics = c("Tot", "f", "C"),
varNames = c("region", "gender", "ecoNew"),
rule = "u",
verbose = FALSE
)
# specifying input to define common cells
common_cells <- list()
# variable "gender"
common_cells$v.gender <- list()
common_cells$v.gender[[1]] <- "gender" # variable name in "p1"
common_cells$v.gender[[2]] <- "gender" # variable name in "p2"
# "gender" has equal characteristics on both datasets -> keyword "ALL"
common_cells$v.gender[[3]] <- "ALL"
# variables: "ecoOld" and "ecoNew"
common_cells$v.eco <- list()
common_cells$v.eco[[1]] <- "ecoOld" # variable name in "p1"
common_cells$v.eco[[2]] <- "ecoNew" # variable name in "p2"
# vector of common characteristics: "A" and "B" in variable "ecoOld" in 'p1'
common_cells$v.eco[[3]] <- c("A", "B")
# correspond to characteristics "C" and "D" in variable "ecoNew" in "p2"
common_cells$v.eco[[4]] <- c("C", "D")
# protect the linked data
result <- protectLinkedTables(
objectA = p1,
objectB = p2,
commonCells = common_cells,
method = "HITAS",
verbose = TRUE
)
# having a look at the results
result.tab1 <- result[[1]]
result.tab2 <- result[[2]]
summary(result.tab1)
summary(result.tab2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.