h2h_long | R Documentation |
Functions to compute Head-to-Head values in long pair-value format.
h2h_long(cr_data, ..., fill = list()) to_h2h_long(mat, value = "h2h_value", drop = FALSE) ## S3 method for class 'h2h_long' as_tibble(x, ...)
cr_data |
Competition results ready for |
... |
Name-value pairs of Head-to-Head functions (see Details). |
fill |
A named list that for each variable supplies a single value to
use instead of |
mat |
Matrix of Head-to-Head values. |
value |
String name to be used for column with Head-to-Head value. |
drop |
Use |
x |
Object to be converted to tibble. |
h2h_long()
computes Head-to-Head values in
long format. It allows computation of multiple
Head-to-Head values at the same time by supplying multiple summary functions
in ...
. If no function is supplied in ...
, it returns all appropriate
combinations of matchups (see next paragraph).
After computing Head-to-Head values of actually present matchups, they are
aligned with "levels" (see levels2()
) of player
vector (after applying
as_longcr()
). This is a way to target function on fixed set of players by
using factor columns. The procedure is:
Implicit missing matchups are turned into explicit (by adding corresponding rows with filling values in Head-to-Head columns) by using tidyr's complete().
All matchups not containing players from "levels" are removed.
Use fill
as in complete()
to control filling values. To drop those rows
use tidyr's drop_na().
to_h2h_long()
takes object of h2h_mat structure and converts
it into h2h_long
object with value column named as stored in value
. Use
drop = TRUE
to remove rows with missing values in value column (but not in
players').
An object of class h2h_long
which is a tibble
with columns player1
, player2
and those, produced by Head-to-Head
functions (for h2h_long()
maybe none).
as_tibble() applied to h2h_long
object drops
h2h_long
class.
Head-to-Head value is a summary statistic of direct confrontation between two
players. It is assumed that this value can be computed based only on the
players' matchups. In other words, every game is converted
into series of "subgames" between ordered pairs of players (including
selfplay) which is stored as widecr object. After that, summary of item,
defined by columns player1
and player2
, is computed using
summarise_item()
.
That said, name-value pairs of Head-to-Head functions should be defined as
for summarise_item()
applied to data with columns game
, player1
,
score1
, player2
, score2
.
Matrix format of Head-to-Head values.
Common Head-to-Head functions.
ncaa2005 %>% h2h_long( mean_score = mean(score1), mean_abs_score = mean(abs(score1 - score2)) ) ncaa2005[-(1:2), ] %>% h2h_long( mean_score = mean(score1), fill = list(mean_score = 0) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.