Functions to compute Head-to-Head values in matrix pair-value format.
h2h_mat(cr_data, ..., fill = NULL) to_h2h_mat(tbl, value = NULL, fill = NULL)
Competition results ready for
Name-value pairs of Head-to-Head functions (see Details).
A single value to use instead of
Data frame in long format of Head-to-Head values.
String name for column with Head-to-Head value.
An object of class
h2h_mat which is a matrix with row names
indicating first player in matchup, col names - second and values -
h2h_mat() computes Head-to-Head values in
matrix format. It allows multiple Head-to-Head
... but only first (if present) will be used. Basically, it
uses supplied function to compute long format of Head-to-Head values and then
transforms it naturally to matrix, filling missing values
to_h2h_mat() takes object of h2h_long structure and converts it into
h2h_mat using column with name
value for values and filling data for
implicitly missing (not explicitly provided in
tbl) player pairs with
NULL it takes first non-player column. If there is no
such column, it will use vector of dummy values (
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
player2, is computed using
That said, name-value pairs of Head-to-Head functions should be defined as
summarise_item() applied to data with columns
# Only first function is used ncaa2005 %>% h2h_mat( mean_score = mean(score1), mean_abs_score = mean(abs(score1 - score2)) )#>#> # A matrix format of Head-to-Head values: #> Duke Miami UNC UVA VT #> Duke 8.75 7.0 21.0 7.0 0.0 #> Miami 52.00 34.5 34.0 25.0 27.0 #> UNC 24.00 16.0 12.5 7.0 3.0 #> UVA 38.00 17.0 5.0 18.5 14.0 #> VT 45.00 7.0 30.0 52.0 33.5ncaa2005[-(1:2), ] %>% h2h_mat(mean_score = mean(score1), fill = 0)#> # A matrix format of Head-to-Head values: #> Duke Miami UNC UVA VT #> Duke 9.333333 0.00000 21.0 7.0 0.0 #> Miami 0.000000 28.66667 34.0 25.0 27.0 #> UNC 24.000000 16.00000 12.5 7.0 3.0 #> UVA 38.000000 17.00000 5.0 18.5 14.0 #> VT 45.000000 7.00000 30.0 52.0 33.5