% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/helpers_table1.R
\name{process_catbin_direct}
\alias{process_catbin_direct}
\title{Process a single categorical or binary variable for Table 1}
\usage{
process_catbin_direct(
  v,
  dat,
  levels_to_show = c("all", "non_zero"),
  predefined_levels = NULL,
  N_all,
  N_ref,
  N_tx,
  idx_ref,
  idx_tx,
  w_vec,
  grp_vec,
  using_w,
  n_decimal = 0,
  pct_decimal = 1,
  use_abs = FALSE,
  calculate_existing = FALSE,
  verbose = TRUE
)
}
\arguments{
\item{v}{Character string. Variable name.}

\item{dat}{Data frame containing \code{v}, a \code{.grp} column (0/1),
and optionally a \code{..w} weights column.}

\item{levels_to_show}{Character. Either \code{"all"} (show every level) or
\code{"non_zero"} (show only non-baseline levels).}

\item{predefined_levels}{Character vector of levels to display, or \code{NULL}
to use levels found in the data.}

\item{N_all}{Integer. Total number of patients.}

\item{N_ref}{Integer. Number of reference-group patients.}

\item{N_tx}{Integer. Number of exposed-group patients.}

\item{idx_ref}{Integer vector. Row indices for the reference group.}

\item{idx_tx}{Integer vector. Row indices for the exposed group.}

\item{w_vec}{Numeric vector. Pre-computed weight vector for all rows.}

\item{grp_vec}{Integer vector. Pre-computed group vector (0/1) for all rows.}

\item{using_w}{Logical. Whether weights are active (any weight > 1).}

\item{n_decimal}{Integer. Decimal places for counts (default 0).}

\item{pct_decimal}{Integer. Decimal places for percentages (default 1).}

\item{use_abs}{Logical. Use absolute values for differences (default FALSE).}

\item{calculate_existing}{Logical. If TRUE, compute non-missing counts
(default FALSE).}

\item{verbose}{Logical. Print progress messages (default TRUE).}
}
\value{
A matrix of list rows (one per level), or \code{NULL} if the
variable is not in \code{dat} or has no displayable levels.
}
\description{
Computes weighted counts, percentages, crude differences, and standardized
mean differences for each level of a categorical or binary variable.
Uses \code{stats::xtabs} to compute the full weighted cross-tabulation
once per variable, then extracts per-level results efficiently.
}
\keyword{internal}
