% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/forest_df.R
\name{forest_df}
\alias{forest_df}
\title{Build a compatible data frame for forest plots}
\usage{
forest_df(uni, multi = NULL, desc = NULL, digits = 2)
}
\arguments{
\item{uni}{A \code{gtregression} object from \code{uni_reg()}. If
\code{multi} is supplied without \code{uni}, the multivariable object is
plotted as a single effect column.}

\item{multi}{Optional \code{gtregression} object from \code{multi_reg()}.}

\item{desc}{Optional descriptive table object from \code{descriptive_table()}.}

\item{digits}{Number of digits used when formatting confidence intervals.}
}
\value{
A data frame with display columns, formatted effect-size columns,
  standard-error columns, and plotting attributes used by \code{forest_reg()}
  to draw confidence intervals.
}
\description{
Creates the tabular input used by \code{forest_reg()} from \code{uni_reg()},
\code{multi_reg()}, and optionally \code{descriptive_table()} objects. This
function is useful when users want to inspect, edit, or reuse the exact data
that will be passed to the forest plot. Stratified regression objects are
also supported when supplied one at a time; the returned data frame keeps the
characteristic rows once and places strata side by side as separate effect
columns for \code{forest_reg()}.
}
\examples{
birthwt_data <- data_birthwt |>
  dplyr::mutate(
    smoke = factor(smoke, levels = c(0, 1), labels = c("No", "Yes")),
    ht = factor(ht, levels = c(0, 1), labels = c("No", "Yes")),
    low = factor(low, levels = c(0, 1), labels = c("Normal BW", "Low BW"))
  )

uni_or <- uni_reg(
  birthwt_data,
  outcome = "low",
  exposures = c("age", "lwt", "smoke", "ht"),
  approach = "logit"
)
multi_or <- multi_reg(
  birthwt_data,
  outcome = "low",
  exposures = c("smoke", "ht"),
  adjust_for = c("age", "lwt"),
  approach = "logit"
)

forest_data <- forest_df(uni_or, multi_or)
head(forest_data)
}
