widecr: Wide format of competition results

Description Usage Arguments Details Value Wide format of competition results Repairing See Also Examples

Description

Functions for dealing with competition results in wide format.

Usage

1
2
3
4
5
6
is_widecr(cr_data)

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

## S3 method for class 'widecr'
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_widecr() is S3 method for converting data to widecr. 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 widecr class to it.

When applying as_widecr() to proper (check via is_longcr() is made) longcr object, conversion is made:

For appropriate widecr objects as_widecr returns its input and throws error otherwise.

Value

is_widecr() returns TRUE if its argument is appropriate object of class widecr: it should inherit classes widecr, tbl_df (in other words, to be tibble) and have complete pairs of "player"-"score" columns where pair is detected by digits after strings "player" and "score" respectively. Columns of "player" and "score" types shouldn't have any extra symbols except type name and digits after it. All other columns are considered as "extra columns".

as_widecr() returns an object of class widecr.

as_tibble() applied to widecr object drops widecr class.

Wide format of competition results

It is assumed that competition consists from multiple games (matches, comparisons, etc.). One game can consist only from constant 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).

widecr inherits from tibble. Data should be organized in pairs of columns "player"-"score". Identifier of a pair should go after respective keyword and consist only from digits. For example: player1, score1, player2, score2. Order doesn't matter. Extra columns are allowed.

To account for R standard string ordering, identifiers of pairs should be formatted with leading zeros (when appropriate). For example: player01, score01, ..., player10, score10.

Column game for game identifier is optional. If present it will be used in conversion to longcr format via as_longcr().

Repairing

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

See Also

Long format

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cr_data <- data.frame(
  playerA = 1:10,
  playerB = 2:11,
  scoreC = 11:20,
  scoreB = 12:21,
  otherColumn =  101:110
)
cr_data_wide <- as_widecr(cr_data, repair = TRUE)

is_widecr(cr_data_wide)

as_tibble(cr_data_wide)

echasnovski/comperes documentation built on Oct. 22, 2018, 9:25 p.m.