swapOrientation {dvir}R Documentation

Swap orientation of an assignment table

Description

This function switches the roles of victims and missing persons in a table of assignments, from PM-oriented (victims as column names) to AM-oriented (missing persons as column names), and vice versa. In both version, each row describes the same assignment vector.

Usage

swapOrientation(df, from = NULL, to = NULL)

Arguments

df

A data frame. Each row is an assignment, with * representing non-pairing.

from

A character vector; either victims or missing persons. By default, the column names of df. The only time this argument is needed, if when df has other columns in addition, as in output tables of dviJoint().

to

The column names of the transformed data frame. If missing, the unique elements of df are used. An error is raised if to does not contain all elements of df (except *).

Value

A data frame with nrow(df) rows and length(to) columns.

Examples

df = example1 |> generatePairings() |> expand.grid.nodup()
df
swapOrientation(df)

# Swap is idempotent
stopifnot(identical(swapOrientation(swapOrientation(df)), df))


[Package dvir version 3.3.0 Index]