pairgames: Competition results with games between two players

pairgamesR Documentation

Competition results with games between two players

Description

Functions for competition results with games between two players.

Usage

to_pairgames(cr_data)

is_pairgames(cr_data)

Arguments

cr_data

Competition results in format ready for as_longcr().

Details

Pairgames is a term for competition results with games between two players.

to_pairgames() is a function that converts competition results into pairwise games: it drops games with one player and for every game with 3 and more players this function transforms it into set of separate games between unordered pairs of players. In other words the result is a set of unordered matchups (as different games) between different players.

Important notes:

  • New game identifiers are integers, order of which respects order of games stored in cr_data (based on first occurrence in long format). There is no particular order in subgames of games with 3 and more players.

  • Order in which players are assigned to player1 or player2 column in general shouldn't agree with any order in cr_data.

  • Any column except game, player and score will be dropped after conversion to longcr.

  • NA and NaN in players are allowed. They are treated as different players.

  • to_pairgames() is rather compute-intensive and can take much time for competition results with many games.

Value

to_pairgames() returns a competition results of pairwise games as widecr object with two players.

is_pairgames() returns a boolean value of whether cr_data contains only games between two players.

Examples

cr_data <- data.frame(
  game = c(rep(1:5, each = 3), 6),
  player = c(rep(1:5, times = 3), 1),
  score = 101:116,
  extraCol = -(1:16)
)

to_pairgames(cr_data)

# Missing values
cr_data_na <- data.frame(
  game = rep(1L, 3),
  player = c(1, NA, NA),
  score = 1:3
)
to_pairgames(cr_data_na)

# Checks
is_pairgames(cr_data)
is_pairgames(to_pairgames(cr_data))

comperes documentation built on March 7, 2023, 7:02 p.m.