Functions for dealing with competition results in wide format.
1 2 3 4 5 6
Data of competition results (convertible to tabular).
Whether to repair input.
Additional arguments to be passed to or from methods.
Object to be converted to tibble.
as_widecr() is S3 method for converting data to
using default method if
TRUE it also tries to fix
possible problems (see "Repairing"). If
FALSE it converts
cr_data to tibble and adds
widecr class to it.
as_widecr() to proper (check via
is_longcr() is made)
longcr object, conversion is made:
All columns except "game", "player" and "score" are dropped.
Conversion from long to wide format is made. The number of "player"-"score"
pairs is taken as the maximum number of players in game. If not all games are
played between the same number of players then there will be
NA's in some
game is preserved in output and is used for arranging in
as_widecr returns its input and
throws error otherwise.
TRUE if its argument is appropriate object
widecr: it should inherit classes
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
as_tibble() applied to
widecr object drops
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.
game for game identifier is optional. If present it will be used in
longcr format via
repair = TRUE (default) in
as_widecr() means that its result is
going to be repaired with following actions:
Detect columns with names containing "player" or "score" (ignoring case). All other columns are treated as "extra".
Extract first occurrence of "player" or "score" (ignoring case) from names of detected columns. Everything after extracted word is treated as identifier of "player"-"score" pair.
Convert these identifiers to numeric form with
Convert identifiers once again to character form with possible leading zeros (to account for R standard string ordering).
Spread pairs to appropriate columns with possible column adding (which
were missed in original pairs based on information of pair identifier) with
Note that if there is column
game (exactly matched) it is placed as
Note that the order (and numeration) of pairs can change.
1 2 3 4 5 6 7 8 9 10 11 12
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.