get_wl_matrix: Converts win-loss dataframe to win-loss matrix

Description Usage Arguments Value Further details Examples

View source: R/get_wl_matrix.R

Description

Converts win-loss dataframe to win-loss matrix

Usage

1
get_wl_matrix(df, ties = "remove")

Arguments

df

A results or win-loss dataframe

ties

How to handle ties, default is ties="remove" Alternative is ties="keep"

Value

A win-loss matrix

Further details

Input dataframes or matrices with only 2 columns are considered to be winners in column 1 and losers in column 2. If input dataframe has three columns, the third column will be the result of the interaction between column 1 subject and column 2 subject. The result can be in the "W/L/T" format or "1/0/0.5" format. See get_wl_df: for further info.

Examples

1
2
3
4

Example output

      loser
winner AH GN JP KU MO MQ NZ PQ
    AH  0  1  1  2  1  0  1  1
    GN  1  0  0  0  1  1  1  1
    JP  1  2  0  1  2  0  1  2
    KU  0  2  1  0  1  0  1  1
    MO  1  1  0  1  0  0  2  0
    MQ  2  1  2  2  2  0  2  1
    NZ  1  1  1  1  0  0  0  1
    PQ  1  1  0  1  2  1  1  0
      loser
winner AU BC DO EP FL GQ GY HU HV JU MO MV NV OR QW
    AU  0  2  2  2  2  1  1  0  0  1  2  1  0  1  2
    BC  0  0  0  2  2  0  0  1  1  1  2  1  1  0  2
    DO  0  1  0  0  1  2  1  0  0  1  0  0  2  0  2
    EP  0  0  2  0  2  1  1  1  1  0  1  1  1  1  2
    FL  0  0  0  0  0  1  0  1  2  1  0  1  0  2  1
    GQ  1  2  0  0  0  0  2  1  1  1  0  0  1  1  2
    GY  1  2  1  1  2  0  0  0  1  0  1  1  1  2  1
    HU  2  0  1  1  1  1  0  0  1  0  2  0  1  1  2
    HV  2  0  1  1  0  1  1  1  0  1  0  2  1  1  1
    JU  1  0  0  1  0  1  2  2  1  0  0  2  2  1  0
    MO  0  0  1  1  2  1  1  0  1  2  0  1  2  2  0
    MV  1  1  2  1  1  1  1  2  0  0  1  0  2  1  1
    NV  1  0  0  0  2  1  1  1  1  0  0  0  0  0  0
    OR  1  2  1  0  0  1  0  0  1  0  0  1  2  0  1
    QW  0  0  0  0  1  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0 0.0 0.0 0.0
      loser
winner   A   B   C   D   E   F   G   H   I   J   K
     A   0 257  35  16 110 128 124 155 159 178  60
     B   8   0  21  10  63  79  58  86  51 126  32
     C   0  19   0   4  16  16  12  21  20  12  18
     D   0   2   1   0   3   3   3   8   1   7   5
     E   1   8   4   2   0  19  17  23  18  35  16
     F   1   1   2   2   1   0  24  17  55  45   6
     G   2   4   2   2   4   7   0   7   6   9   4
     H   2   1   2   4   2   6   5   0  13  18   2
     I   2   1   0   0   0   1   1   1   0  17   2
     J   1   1   0   1   0   2   1   4   3   0  13
     K   1   2   0   0   0   1   8   3   1   4   0

compete documentation built on May 29, 2017, 1:39 p.m.