h2h_mat | R Documentation |
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)
cr_data |
Competition results ready for |
... |
Name-value pairs of Head-to-Head functions (see Details). |
fill |
A single value to use instead of |
tbl |
Data frame in long format of Head-to-Head values. |
value |
String name for column with Head-to-Head value. |
h2h_mat()
computes Head-to-Head values in
matrix format. It allows multiple Head-to-Head
functions in ...
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
with fill
.
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
fill
. If value
is NULL
it takes first non-player column. If there is no
such column, it will use vector of dummy values (NA
s or fill
s).
An object of class h2h_mat
which is a matrix with row names
indicating first player in matchup, col names - second and values -
Head-to-Head 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 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
.
Long format of Head-to-Head values.
Common Head-to-Head functions.
# Only first function is used ncaa2005 %>% h2h_mat( mean_score = mean(score1), mean_abs_score = mean(abs(score1 - score2)) ) ncaa2005[-(1:2), ] %>% h2h_mat(mean_score = mean(score1), fill = 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.