Description Usage Arguments Value Examples
This function computes (with respect to the raw input data) the indices of all
contributing units to given cells identified by ids
.
1 | contributing_indices(prob, ids = NULL)
|
prob |
a sdcProblem object created with |
ids |
a character vector containing default ids (strIDs) that define table
cells. Valid inputs can be extracted by using |
a named list where names correspond to the given
ids' and the values
to the row numbers within the raw input data.
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 | # loading test data
data("microData1", package="sdcTable")
# specify hierarchies for `age` and `region`
dim_region <- hier_create(root = "Total", nodes = LETTERS[1:4])
dim_gender <- hier_create(root = "Total", nodes = c("male", "female"))
dl <- list(region = dim_region, gender = dim_gender)
# no variables holding counts, numeric values, weights or sampling
# weights are available in the input data
# using variable names is also possible
prob <- makeProblem(
data = microData1,
dimList = dl
)
df <- sdcProb2df(prob, dimCodes = "original")
# which units contribute to cell region = "A" and gender = "female"?
# compute the id ("0101")
df[region == "A" & gender == "female", strID]
# which indices contribute to the cell?
ids <- contributing_indices(prob = prob, ids = "0101")
# check
dataObj <- get.sdcProblem(prob, "dataObj")
rawData <- slot(dataObj, "rawData")
rawData[ids[["0101"]]]
# compute contributing ids for each cell
contributing_indices(prob)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.