% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/contributing_indices.R
\name{contributing_indices}
\alias{contributing_indices}
\title{Compute contributing units to table cells}
\usage{
contributing_indices(prob, ids = NULL)
}
\arguments{
\item{prob}{a \link[=sdcProblem-class]{sdcProblem} object created with \code{\link[=makeProblem]{makeProblem()}}.}

\item{ids}{a character vector of cell identifiers (\code{strID}). If \code{NULL},
indices are computed for all cells in the table. Valid identifiers can
be found in the \code{strID} column of the data frame returned by \code{\link[=sdcProb2df]{sdcProb2df()}}.}
}
\value{
a named list where each element contains integer indices of the
contributing rows in the raw microdata.
}
\description{
This function maps aggregated table cells back to their constituent microdata.
It returns the row indices of the raw input data that contribute to specific
cells identified by \code{ids}.
}
\examples{
# load test problem
p <- sdc_testproblem(with_supps = FALSE)
dt <- sdcProb2df(p, dimCodes = "original")

# find the strID for a specific cell (e.g., region "A" and gender "female")
target_id <- dt[region == "A" & gender == "female", strID]

# compute contributing indices for this cell
contr_list <- contributing_indices(prob = p, ids = target_id)

# view the contributing raw data rows
rawData <- slot(get.sdcProblem(p, "dataObj"), "rawData")
rawData[contr_list[[target_id]]]

# compute indices for all cells in the table
all_indices <- contributing_indices(p)
}
