qm_matching: Constructor for qm_matching objects

View source: R/qm_matching.R

qm_matchingR Documentation

Constructor for qm_matching objects

Description

The qm_matching function constructs a qm_matching object from existing matched group labels. The function does not derive matchings from sets of data points; see quickmatch for that functionality.

Usage

qm_matching(group_labels, unassigned_labels = NULL, ids = NULL)

Arguments

group_labels

a vector containing each unit's group label.

unassigned_labels

labels that denote unassigned units. If NULL, NA values in group_labels are used to denote unassigned points.

ids

IDs of the units. Should be a vector of the same length as group_labels or NULL. If NULL, the IDs are set to 1:length(group_labels).

Details

qm_matching objects are based on integer vectors, and it indexes matched groups starting with zero. The qm_matching class inherits from the scclust class.

Value

Returns a qm_matching object with the matching described by the provided labels.

Examples

# 10 units in 3 matched groups
matches1 <- qm_matching(c("A", "A", "B", "C", "B",
                          "C", "C", "A", "B", "B"))

# 8 units in 3 matched groups, 2 units unassigned
matches2 <- qm_matching(c(1, 1, 2, 3, 2,
                          NA, 3, 1, NA, 2))

# Custom labels indicating unassiged units
matches3 <- qm_matching(c("A", "A", "B", "C", "NONE",
                          "C", "C", "NONE", "B", "B"),
                        unassigned_labels = "NONE")

# Two different labels indicating unassiged units
matches4 <- qm_matching(c("A", "A", "B", "C", "NONE",
                          "C", "C", "0", "B", "B"),
                        unassigned_labels = c("NONE", "0"))

# Custom unit IDs
matches5 <- qm_matching(c("A", "A", "B", "C", "B",
                          "C", "C", "A", "B", "B"),
                        ids = letters[1:10])


fsavje/quickmatch documentation built on Dec. 11, 2023, 5:09 a.m.