# Basic usage
left <- data.frame(
id = 1:5,
treatment = 1,
age = c(25, 30, 35, 40, 45),
income = c(45000, 52000, 48000, 61000, 55000)
)
right <- data.frame(
id = 6:10,
treatment = 0,
age = c(24, 29, 36, 41, 44),
income = c(46000, 51500, 47500, 60000, 54000)
)
result <- match_couples(left, right, vars = c("age", "income"))
matched_data <- join_matched(result, left, right)
head(matched_data)
# Specify which variables to include
matched_data <- join_matched(
result, left, right,
left_vars = c("treatment", "age", "income"),
right_vars = c("age", "income"),
suffix = c("_treated", "_control")
)
# Without distance or pair_id
matched_data <- join_matched(
result, left, right,
include_distance = FALSE,
include_pair_id = FALSE
)
Run the code above in your browser using DataLab