setInfo {sdcTable} | R Documentation |
Set/Update information in sdcProblem
or problemInstance
objects
Description
Function setInfo()
is used to update values in
sdcProblem
or problemInstance
objects
Usage
setInfo(object, type, index, input)
Arguments
object |
an object of class |
type |
a scalar character specifying the kind of information that
should be changed or modified; if
|
index |
numeric vector defining cell-indices for which which values in a specified slot should be changed|modified |
input |
numeric or character vector depending on argument
|
Value
a sdcProblem
- or problemInstance
object
Author(s)
Bernhard Meindl bernhard.meindl@statistik.gv.at
Examples
# load example-problem with suppressions
# (same as example from ?primarySuppression)
p <- sdc_testproblem(with_supps = TRUE)
# which is the overall total?
idx <- which.max(getInfo(p, "freq")); idx
# we see that the cell with idx = 1 is the overall total and its
# anonymization state of the total can be extracted as follows:
print(getInfo(p, type = "sdcStatus")[idx])
# we want this cell to never be suppressed
p <- setInfo(p, type = "sdcStatus", index = idx, input = "z")
# we can verify this:
print(getInfo(p, type = "sdcStatus")[idx])
# changing slot 'UPL' for all cells
inp <- data.frame(
strID = getInfo(p, "strID"),
UPL_old = getInfo(p, "UPL")
)
inp$UPL_new <- inp$UPL_old + 1
p <- setInfo(p, type = "UPL", index = 1:nrow(inp), input = inp$UPL_new)