Binary comparisons from a ranking object. Ties are not taken into account, then they are added as NA's.

set_binomialfreq(object, drop.null = FALSE, disaggregate = FALSE)

Arguments

object

an object of class rankings, grouped_rankings or paircomp

drop.null

logical, an optional argument to remove null contests

disaggregate

logical, if TRUE binaries are disaggregated by individual contests

Value

A data.frame with binary rank of pairwise contests:

player1

a factor with n levels for the first player in the contests

player2

a factor with n levels (same as player1) for the second player in the contests

win1

number of times player1 wins against player2

win2

number of times player2 wins against player1

References

Turner H. & Firth D. (2012). Journal of Statistical Software, 48(9), 1–21. doi:10.18637/jss.v048.i09

See also

Other rank functions: rank_numeric(), rank_tricot(), rank_tricot2(), set_paircomp()

Author

Kauê de Sousa

Examples

library("PlackettLuce")

R = matrix(c(1, 2, 0, 0,
              4, 1, 2, 3,
              2, 4, 3, 1,
              1, 2, 3, 0,
              2, 1, 1, 0,
              1, 0, 3, 2), nrow = 6, byrow = TRUE)
colnames(R) = c("apple", "banana", "orange", "pear")

R = as.rankings(R)

set_binomialfreq(R)
#>    player1 player2  win1  win2
#>      <fct>   <fct> <int> <int>
#> 1:   apple  banana     3     2
#> 2:   apple  orange     3     2
#> 3:  banana  orange     2     1
#> 4:   apple    pear     1     2
#> 5:  banana    pear     1     1
#> 6:  orange    pear     1     2

set_binomialfreq(R, disaggregate = TRUE)
#>        id player1 player2  win1  win2
#>     <int>   <fct>   <fct> <int> <int>
#> 1:      1   apple  banana     1     0
#> 2:      2   apple  banana     0     1
#> 3:      2   apple  orange     0     1
#> 4:      2  banana  orange     1     0
#> 5:      2   apple    pear     0     1
#> ---                                  
#> 17:     5   apple  banana     0     1
#> 18:     5   apple  orange     0     1
#> 21:     6   apple  orange     1     0
#> 41:     6   apple    pear     1     0
#> 61:     6  orange    pear     0     1