Functions for dealing with competition results in long 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_longcr() 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
tibble and adds
longcr class to it.
as_longcr() to proper (check via
is_widecr() is made)
widecr object, conversion is made:
If there is column
game then it is used as game identifier. Else
treat every row as separate game data.
Every "player"-"score" pair for every game is converted to separate row with adding the appropriate extra columns.
Result is arranged by
game and identifier of a "player"-"score" pair
(extra symbols after "player" and "score" strings in input column names) in
TRUE then repair is done.
as_longcr() returns its input and
throws error otherwise.
TRUE if its argument is appropriate object of
longcr: it should inherit classes
tbl_df (in other
words, to be tibble) and have "game", "player", "score"
among column names.
as_longcr() returns an object of class
as_tibble() applied to
longcr object drops
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:
game - game identifier.
player - player identifier.
score - score of particular player in particular game.
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.
repair = TRUE (default) in
as_longcr() means that its result is
going to be repaired with following actions:
Detect columns exactly matching "game", "player" or "score". Those are used in the output. If all are detected matched columns are put in the beginning. Other columns are preserved.
If not all columns were exactly matched, detect first columns with names containing "game", "player" or "score" (ignoring case). If there are many matching names for one output name then the first one is used. In case of imperfect match, message is given. All other columns are treated as "extra".
If some legitimate names aren't detected, respective columns are created
and filled with
NA_integer_. Also a message is given.
If in one game some player listed more than once, the first record is taken.
Return the tibble with at least 3 appropriate for
longcr columns and
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.