% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/matching_output.R
\name{match_data}
\alias{match_data}
\alias{match_data.matching_result}
\alias{match_data.full_matching_result}
\alias{match_data.cem_result}
\alias{match_data.subclass_result}
\title{Extract Analysis-Ready Data from Matching Results}
\usage{
match_data(result, ...)

\method{match_data}{matching_result}(result, left, right, left_id = "id", right_id = "id", ...)

\method{match_data}{full_matching_result}(result, left, right, left_id = "id", right_id = "id", ...)

\method{match_data}{cem_result}(result, left, right, left_id = "id", right_id = "id", ...)

\method{match_data}{subclass_result}(result, data = NULL, ...)
}
\arguments{
\item{result}{A couplr result object (matching_result, full_matching_result,
cem_result, or subclass_result)}

\item{...}{Additional arguments passed to methods}

\item{left}{Data frame of left (treated) units}

\item{right}{Data frame of right (control) units}

\item{left_id}{Name of ID column in left (default: \code{"id"})}

\item{right_id}{Name of ID column in right (default: \code{"id"})}

\item{data}{Data frame containing all units (for CEM and subclassification,
left and right are not always needed separately)}
}
\value{
A tibble with all original variables plus standardized columns:
\describe{
\item{id}{Unit identifier}
\item{treatment}{1 for left/treated, 0 for right/control}
\item{weights}{Matching weights}
\item{subclass}{Matched group/stratum identifier}
\item{distance}{Matching distance (where applicable)}
}
}
\description{
A generic function that converts any couplr matching result into a single
analysis-ready data frame with \code{weights}, \code{subclass}, and
\code{distance} columns. This is the couplr equivalent of MatchIt's
\code{match.data()}.
}
\details{
The output format is compatible with downstream packages like \pkg{cobalt},
\pkg{WeightIt}, and \pkg{marginaleffects}. The stacked (long) format with
\code{treatment} and \code{weights} columns is the standard layout expected
by these tools.
}
\examples{
set.seed(42)
left <- data.frame(id = 1:5, age = c(25, 35, 45, 55, 65))
right <- data.frame(id = 6:15, age = runif(10, 20, 70))
result <- match_couples(left, right, vars = "age")
md <- match_data(result, left, right)
head(md)

}
