% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/setInfo.R
\name{setInfo}
\alias{setInfo}
\title{Set/Update information in \code{sdcProblem} or \code{problemInstance} objects}
\usage{
setInfo(object, type, index, input)
}
\arguments{
\item{object}{an object of class \code{sdcProblem} or \code{problemInstance}}

\item{type}{a scalar character specifying the kind of information that
should be changed or modified; if \code{object} inherits class \code{problemInstance}, the
slots are directly changed, otherwise the values within slot \code{problemInstance}
are updated. Valid choices are:
\itemize{
\item \code{lb}: lower possible bounds for the cell
\item \code{ub}: max. upper bound for the given cell
\item \code{LPL}: lower protection level
\item \code{SPL}: sliding protection level
\item \code{UPL}: upper protection level
\item \code{sdcStatus}:  cell-status
}}

\item{index}{numeric vector defining cell-indices for which which values in a specified slot should be changed|modified}

\item{input}{numeric or character vector depending on argument \code{type} with its length matching the length of argument \code{index}
\itemize{
\item character vector if type matches 'sdcStatus'
\item a numeric vector if type matches 'lb', 'ub', 'LPL', 'SPL' or 'UPL'
}}
}
\value{
a \code{sdcProblem}- or \code{problemInstance} object
}
\description{
Function \code{\link[=setInfo]{setInfo()}} is used to update values in
\code{sdcProblem} or \code{problemInstance} objects
}
\section{Cell Status Codes}{


When an object of class \code{sdcProblem} is created, every cell is assigned an
internal anonymization state. These codes track the lifecycle of a
cell throughout the suppression process:
\itemize{
\item \code{"s"} (\emph{"Publishable"}): The cell is safe and can be published (default).
\item \code{"z"}(\emph{"Forced Publishable"}): The cell must not be suppressed under any
circumstances.
\item \code{"u"} (*"Primary Suppressed"): The cell is identified as sensitive and
requires protection (typically assigned via \code{\link[=primarySuppression]{primarySuppression()}}).
\item \code{"x"} (\emph{"Secondary Suppressed"}): The cell is suppressed to protect
primary sensitive cells (typically assigned via \code{\link[=protectTable]{protectTable()}}).
\item \code{"w"} (\emph{"Extension Cell"}): The cell exists in the object but will never
be published. It is treated as a suppressed cell by internal algorithms.
This is useful if it is known in advance that specific codes of a hierarchy
will be excluded from publication.
}

Initially in \code{\link[=makeProblem]{makeProblem()}}, cells are coded as \code{"s"} or \code{"z"}. Their
status transitions to \code{"u"} or \code{"x"} as suppression algorithms are applied.

While \code{\link[=setInfo]{setInfo()}} or \code{\link[=change_cellstatus]{change_cellstatus()}} allow for manual state
modifications, \code{\link[=primarySuppression]{primarySuppression()}} automatically identifies primary
sensitive cells and assigns state \code{"u"}. In \code{\link[=protectTable]{protectTable()}}, additional
cells are identified and set to \code{"x"} to ensure all primary sensitive
cells are adequately protected.
}

\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)
}
\author{
Bernhard Meindl \email{bernhard.meindl@statistik.gv.at}
}
