ranked_sort: Find optimal pairings from two sets based on their rankings

View source: R/balance_around.R

ranked_sortR Documentation

Find optimal pairings from two sets based on their rankings

Description

For two sets of unique identifiers, given each member's ranked preference for every member of the other set, find optimal pairings. The two sets are referred to as match_to and match_from. All the members of match_to will be paired to members of match_from, but if there are more members of match_from than match_to there will be unpaired, discarded members of match_from. The inputs are two data frames, one where each observation is a unique combination of each member of match_to and match_from and the preference of that match_to member for match_from, numeric with lower values treated as more preferred. The other data frame contains the preferences of the match_from members for match_to members.

Usage

ranked_sort(
  match_to,
  match_from,
  match_to_idvar = "match_to_id",
  match_from_idvar = "match_from_id",
  match_to_rankvar = "match_to_rank",
  match_from_rankvar = "match_from_rank",
  iteration_limit = 5000
)

Arguments

match_to

Data frame. The preferences of the members of the set to match to for the members of the set to match from. There must be one observation for each unique pairing between the two sets. The variable match_to_idvar must contain the identities of the members of the set to match to; match_from_idvar, the set to match from; and match_to_rankvar the rank preference of the MATCH FROM member for the MATCH FROM member.

match_from

Data frame. The preferences of the members of the set to match from for the members of the set to match to. There must be one observation for each unique pairing between the two sets. The variable match_to_idvar must contain the identities of the members of the set to match to; match_from_idvar, the set to match from; and match_from_rankvar the rank preference of the MATCH FROM member for the MATCH TO member.

match_to_idvar

Character string. The name of the variable in both match_to and match_from that contains the identities of the members in the set to match to. Defaults to "match_to_id".

match_from_idvar

Character string. The name of the variable in both match_to and match_from that contains the identities of the members in the set to match from. Defaults to "match_from_id".

match_to_rankvar

Character string. The name of the variable in match_to that contains the rank preference of the match to members for the match from members as a relative numeric value (lower values are more preferred). Defaults to "match_to_rank".

match_from_rankvar

Character string. The name of the variable in match_from that contains the rank preference of the match from members for the match to members as a relative numeric value (lower values are more preferred). Defaults to "match_from_rank".

iteration_limit

Numeric. The maximum number of iterations to attempt to sort before giving up. Defaults to 5000.

Value

A data frame with the variables match_to_id and match_from_id containing the paired members of the two sets.


nstauffer/sample.design documentation built on May 9, 2022, 3:21 a.m.