sdcTable (version 0.20.5)

makeProblem: create sdcProblem-class-objects

Description

Function makeProblem is used to create sdcProblem-class-objects.

Usage

makeProblem(data, dimList, dimVarInd, freqVarInd = NULL, numVarInd = NULL,
  weightInd = NULL, sampWeightInd = NULL)

Arguments

data
a data frame featuring at least one column for each desired dimensional variable. Optionally the input data can feature variables that contain information on cell counts, weights that should be used during the cut and branch algorithm, additional numeric
dimList
a named list with each list element being either a data-frame or a link to a .csv-file containing the complete level-hierarchy of a dimensional variable using a top-to-bottom approach. The list names correspond to variable names that must exist in argumen
dimVarInd
numeric vector (or NULL) defining the column-indices of dimensional variables (defining the table) within argument data
freqVarInd
numeric vector (or NULL) defining the column-indices of a variable holding counts within argument data
numVarInd
numeric vector (or NULL) defining the column-indices of additional numeric variables available in argument data
weightInd
numeric vector of length 1 (or NULL) defining the column-index of a variable holding weights that should be used during as objective coefficients during the cut and branch algorithm to protect primary sensitive cells within argument data
sampWeightInd
numeric vector of length 1 (or NULL) defining the column-index of a variable holding sampling weights within argument data

Value

Examples

Run this code
# loading micro data
sp <- searchpaths()
fn <- paste(sp[grep("sdcTable", sp)], "/data/microData1.RData", sep="")
microData <- get(load(fn))

# having a look at the data structure
str(microData)

# we can observe that we have a micro data set consisting of two spanning
# variables ('region' and 'gender') and one numeric variable ('val')

# specify structure of hierarchical variable 'region'
# levels 'A' to 'D' sum up to a Total
dim.region <- data.frame(
 levels=c('@','@@','@@','@@','@@'),
 codes=c('Total', 'A','B','C','D'),
 stringsAsFactors=FALSE)

# specify structure of hierarchical variable 'gender'
# levels 'male' and 'female' sum up to a Total
dim.gender <- data.frame(
 levels=c('@','@@','@@'),
 codes=c('Total', 'male','female'),
 stringsAsFactors=FALSE)

# create a list with each element being a data-frame containing information
# on a dimensional variables
dimList <- list(dim.region, dim.gender)

# name the list:
# - first list-element: corresponds to variable 'region'
# - second list-element: corresponds to variable 'gender'
names(dimList) <- c('region', 'gender')

# specify the indices where dimensional variables are located
# within the input data

# - variable 'region': first column
# - variable 'gender': second column
dimVarInd <- c(1,2)

# third column containts a numeric variable
numVarInd <- 3

# no variables holding counts, numeric values, weights or sampling
# weights are available in the input data
freqVarInd <- weightInd <- sampWeightInd <- NULL

# creating an object of class \\code{\\link{sdcProblem-class}}
problem <- makeProblem(
 data=microData,
 dimList=dimList,
 dimVarInd=dimVarInd,
 freqVarInd=freqVarInd,
 numVarInd=numVarInd,
 weightInd=weightInd,
 sampWeightInd=sampWeightInd)

# what do we have?
print(class(problem))

Run the code above in your browser using DataLab