swapOrientation {dvir} | R Documentation |
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.
swapOrientation(df, from = NULL, to = NULL)
df |
A data frame. Each row is an assignment, with |
from |
A character vector; either victims or missing persons. By
default, the column names of |
to |
The column names of the transformed data frame. If missing, the
unique elements of |
A data frame with nrow(df)
rows and length(to)
columns.
df = example1 |> generatePairings() |> expand.grid.nodup()
df
swapOrientation(df)
# Swap is idempotent
stopifnot(identical(swapOrientation(swapOrientation(df)), df))