ProtectTable {easySdcTable}R Documentation

Easy interface to sdcTable: Table suppression according to a frequency rule.


GaussSuppression, protectTable or protect_linked_tables is run with a data set as the only required input. One (stacked) or several (unstacked) input variables can hold cell counts. ProtectTableData is a tidy wrapper function, which returns a single data frame instead of a list (info omitted).


  dimVar = 1:NCOL(data),
  freqVar = NULL,
  protectZeros = TRUE,
  maxN = 3,
  method = "Gauss",
  findLinked = TRUE,
  total = "Total",
  addName = FALSE,
  sep = "_",
  removeZeros = FALSE,
  dimList = NULL,
  groupVarInd = NULL,
  ind1 = NULL,
  ind2 = NULL,
  rowData = NULL,
  varNames = paste("var", 1:100, sep = ""),
  split = NULL,
  border = sep,
  revBorder = FALSE,
  freqName = "values",
  totalFirst = FALSE,
  numericOrder = TRUE,
  namesAsInput = TRUE,
  orderAsInput = TRUE,
  sortByReversedColumns = FALSE,
  doUnstack = TRUE,
  removeTotal = TRUE,
  singleOutput = NULL,
  suppression = NA,
  outFreq = "freq",
  outSdcStatus = "sdcStatus",
  outSuppressed = "suppressed",
  infoAsFrame = FALSE,
  IncProgress = IncDefault,
  verbose = FALSE,

ProtectTableData(data, ...)



data frame


The main dimensional variables and additional aggregating variables (name or number).


Variable(s) holding counts or NULL in the case of micro data (name or number).


When TRUE empty cells (count=0) is considered sensitive (i.e. same as allowZeros in primarySuppression).


All cells having counts <= maxN are set as primary suppressed.


Parameter method in protectTable, protect_linked_tables or wrapper methods via PTwrap. Gauss (default) is an additional method that is not available in sdcTable.

  • "SIMPLEHEURISTIC": This method is default in protectable.

  • "SIMPLEHEURISTIC_OLD": As "SIMPLEHEURISTIC" in sdcTable versions prior to 0.32.

  • "OPT", "HITAS", "HYPERCUBE": Other methods in protectable. "HYPERCUBE" is not possible in cases with two linked tables.

  • "SimpleSingle": "SIMPLEHEURISTIC_OLD" with detectSingletons=TRUE when protectZeros=FALSE and "SIMPLEHEURISTIC_OLD" with threshold=1 (can be overridden by input) when protectZeros=TRUE.


  • "Simple": "SIMPLEHEURISTIC_OLD" with detectSingletons=FALSE.

  • "Gauss": GaussSuppression is called with parameters x, candidates, primary and singleton automatically generated. Other parameters (singletonMethod, printInc) can be specified.

Alternatively this parameter can be a named list specifying parameters for running tau-argus (see details). See PTwrap for other (experimental) wrapper methods (see details).


When TRUE, the function may find two linked tables and run protect_linked_tables.


String used to name totals.


When TRUE the variable name is added to the level names, except for variables with most levels.


A character string to separate when addName apply and when creating variable names.


When TRUE, rows with zero count will be removed from the data within the algorithm.


By default, hierarchies will be automatically found from data (see FindDimLists). With non-NULL dimList, these will be changed. In practice this is done by the function ReplaceDimList.


Possible manual specification of list defining the hierarchical variable groups. When NULL (default) this information will be found automatically by FindTableGroup.


Coding of table 1 as indices referring to elements of groupVarInd. This information will be found automatically by FindTableGroup when groupVarInd=NULL.


Coding of table 2 as indices referring to elements of groupVarInd (as ind1 above).


Input to Stack used to generate extra dimVar variables when stacking in cases with several freqvar variables. When NULL rowData will be created automatically by AutoSplit using varNames (see below) and the the freqvar names as input.


The names of the extra dimVar variable(s) made when stacking in cases with several freqvar variables. When length(varNames)>1 several variables may be found by AutoSplit.


Parameter to AutoSplit - see varNames and rowData above. When NULL (default), automatic splitting without needing a split string.


Parameter to AutoSplit - see varNames and rowData above.


Parameter to AutoSplit - see varNames and rowData above..


Input to Stack. The name of the new freqvar variable obtained when stacking in cases with several input freqvar variables.


Parameter controlling how output is sorted.


Parameter controlling how output is sorted. Output is character but sorting can be based on the numeric input variables.


When TRUE those output variables (created by unstacking) that correspond to input will be named as input.


When TRUE output corresponding to input will be ordered as input and kept together as one block.


When TRUE output will be sorted by variables in opposite order.


When FALSE output will not be unstacked (in cases with sever input freqvar variables)


When TRUE the total string (see total above) will be removed from the names of output variables created by unstacking (in cases with sever input freqvar variables).


When TRUE output will be in as single data set. Default is FALSE for unstacked data (in cases with sever input freqvar variables) and otherwise TRUE.


Value used for suppressed elements in suppressed output data. Default is NA.


String used to name output variable(s)


String used to name output variable(s)


String used to name output variable(s)


When TRUE output element info is a data frame (useful in Shiny).


A function to report progress (incProgress in Shiny). Set equal to NULL to turn it off.


Parameter sent to protectTable, protect_linked_tables or runArgusBatchFile.


Further parameters sent to protectTable (possibly via protect_linked_tables) such as timeLimit. Parameters to GaussSuppression, createArgusInput and PTwrap is also possible (see details).


One or two tables are identified automatically and subjected to cell suppression by protectTable (single table) or protect_linked_tables (two linked tables). The tables can alternatively be specified manually by groupVarInd, ind1 and ind2. The output will be on a form similiar to input depending on whether freqVar is a single variable or not. The status of the cells are coded as "u" (primary suppressed), "x" (secondary suppression), and "s" (can be published). This is taken directly from the output from sdcTable. In cases with two linked tables "u" or "x" for common cells are based on output from the first table.


When singleOutput=TRUE output is a list of two elements.


ProtectTable makes a call to the function ProtectTable1.

See Also

See also the vignettes.


 # ==== Example 1 , 8 regions ====
 z1 <- EasyData("z1")        
 ProtectTable(z1,1:2, 3)
 ProtectTableData(z1,1:2, 3)
 ProtectTable(z1, c("region","hovedint"), "ant") # Input by name 
 # --- Unstacked input data ---
 z1w = EasyData("z1w") 
 ProtectTable(z1w, 1, 2:5)
 ProtectTableData(z1w, 1, 2:5)
 ProtectTable(z1w, 1, 2:5, varName="hovedint") 
 ProtectTable(z1w, 1, 2:5, method="HITAS")
 ProtectTable(z1w, 1, 2:5, totalFirst = TRUE, method ="Simple")
 # ==== Example 2 , 11 regions ====
 z2 <- EasyData("z2") 
 ProtectTable(z2,c(1,3,4), 5) # With region-variable kostragr
 # --- Unstacked input data ---
 z2w <- EasyData("z2w") 
 ProtectTable(z2w, 1:2, 4:7) # With region-variable fylke
 ProtectTable(z2w, 1:3, 4:7) # Two linked tables
 ## Not run: 
 # ==== Example 3 , 36 regions ====
 z3 <- EasyData("z3")   
 ProtectTable(z3, c(1,4,5), 7)                               # Three dimensions. No subtotals    
 ProtectTable(z3, 1:6, 7)                                    # Two linked tables  
 # --- Unstacked input data with coded column names 
 z3w <- EasyData("z3w")
 ProtectTable(z3w,1:3,4:15, varName="g12")                   # coding not used when single varName
 ProtectTable(z3w,1:3,4:15, varName=c("hovedint","mnd"))     # Two variables found automatically 
 ProtectTable(z3w,1:3,4:15, varName=c("hovedint","mnd"),
               removeTotal=FALSE)                            # Keep "Total" in variable names 
 # --- Unstacked input data with three level column name coding
 z3wb <- EasyData("z3wb")  
 ProtectTable(z3wb,1:3,4:15,varName=c("hovedint","mnd","mnd2")) # Two variables found automatically
             split="_")                                         # Three variables when splitting
               split="_",namesAsInput=FALSE,orderAsInput=FALSE) # Alternative ouput format
 # ====  Examples Tau-Argus ====              
 exeArgus <- "C:/TauArgus4.1.4/TauArgus.exe" # Change to TauArgus.exe-path in your computer
 pathArgus <- "C:/Users/nnn/Documents"       # Change to an existing folder 
 z1 = EasyData("z1") 
 ProtectTable(z1,1:2,3,method=list(exe=exeArgus, path=pathArgus, typ="tabular", method="OPT")) 
 ProtectTable(z1,1:2,3,method=list(exe=exeArgus, path=pathArgus, typ="tabular", method="MOD")) 
 ProtectTable(z1,1:2,3,method=list(exe=exeArgus, path=pathArgus, typ="tabular", method="GH"))
   method=list(path=pathArgus, exe=exeArgus, method="OPT",
         primSuppRules= list(list(type="freq", n=4, rg=20))))
 z3 <- EasyData("z3")
   method=list(path=pathArgus, exe=exeArgus, method="OPT",
         primSuppRules=list(list(type="freq", n=4, rg=20))))
# ==== Examples with parameter dimList  ====
z2 <- EasyData("z2")
dList <- FindDimLists(z2[-5])
ProtectTable(z2[, c(1,4,5)], 1:2, 3, dimList = dList[c(1,3)])
ProtectTable(z2[, c(1,4,5)], 1:2, 3, dimList = dList[2])
ProtectTable(z2[, c(1,4,5)], 1:2, 3, dimList = DimList2Hrc(dList[c(2,3)]))

## End(Not run)

[Package easySdcTable version 1.0.3 Index]