matchit to Matched objectR/AllGenerics.R, R/methods-matchRanges.R
matchitToMatched.RdCoerce matchit to Matched object
matchitToMatched(x, ranges = NULL, keep_mcols = TRUE)
# S4 method for class 'matchit'
matchitToMatched(x, ranges = NULL, keep_mcols = TRUE)A Matched subclass object, depending on the
value of ranges. If is(ranges, "GRanges") then a
MatchedGRanges object is returned. If
is(ranges, "GInteractions") then a MatchedGInteractions
object is returned. If is.null(ranges) then a
the function first attempts to coerce into the other
classes before coercing to MatchedDataFrame.
# \donttest{
if (!requireNamespace("MatchIt", quietly=TRUE)) {
set.seed(123)
x <- makeExampleMatchedDataSet(type="GRanges")
## Convert GRanges to data.frame, pass to matchit,
## and convert to MatchedGRanges object
set.seed(123)
mgr <-
as.data.frame(x) |>
matchit(formula=feature1 ~ feature2 + feature3,
data=_,
method='nearest',
replace=FALSE) |>
matchitToMatched()
## Compatible with GRanges & Matched functions
mgr
plotCovariate(mgr)
} else {
message("The 'MatchIt' package is required to run this example.")
}
#> The 'MatchIt' package is required to run this example.
# }