longcr {comperes}R Documentation

Long format of competition results

Description

Functions for dealing with competition results in long format.

Usage

is_longcr(cr_data)

as_longcr(cr_data, repair = TRUE, ...)

## S3 method for class 'longcr'
as_tibble(x, ...)

Arguments

cr_data

Data of competition results (convertible to tabular).

repair

Whether to repair input.

...

Additional arguments to be passed to or from methods.

x

Object to be converted to tibble.

Details

as_longcr() is S3 method for converting data to longcr. When using default method if repair is TRUE it also tries to fix possible problems (see "Repairing"). If repair is FALSE it converts cr_data to tibble and adds longcr class to it.

When applying as_longcr() to proper (check via is_widecr() is made) widecr object, conversion is made:

For appropriate longcr objects as_longcr() returns its input and throws error otherwise.

Value

is_longcr() returns TRUE if its argument is appropriate object of class longcr: it should inherit classes longcr, tbl_df (in other words, to be tibble) and have "game", "player", "score" among column names.

as_longcr() returns an object of class longcr.

as_tibble() applied to longcr object drops longcr class.

Long format of competition results

It is assumed that competition consists from multiple games (matches, comparisons, etc.). One game can consist from variable number of players. Inside a game all players are treated equally. In every game every player has some score: the value of arbitrary nature that fully characterizes player's performance in particular game (in most cases it is some numeric value).

longcr inherits from tibble. Data should have at least three columns with the following names:

Extra columns are allowed. Note that if object is converted to widecr, they will be dropped. So it is better to store extra information about "game"-"player" pair as list-column "score" which will stay untouched.

Repairing

Option repair = TRUE (default) in as_longcr() means that its result is going to be repaired with following actions:

See Also

Wide format

Examples

# Repairing example
cr_data <- data.frame(
  playerscoregame_ID = rep(1:5, times = 2),
  gameId = rep(1:5, each = 2),
  scoreS = 31:40,
  scoreSS = 41:50
)
cr_data_long <- as_longcr(cr_data, repair = TRUE)

is_longcr(cr_data_long)

as_tibble(cr_data_long)

[Package comperes version 0.2.7 Index]