List of commonly used functions for computing Head-to-Head values.

h2h_funs

Format

An object of class list of length 9.

Details

h2h_funs is a named list of expressions representing commonly used expressions of Head-to-Head functions for computing Head-to-Head values with h2h_long() or h2h_mat(). Names of the elements will be used as Head-to-Head value names. To use them inside h2h_long() or h2h_mat() use unquoting mechanism from rlang package.

Currently present functions:

  • mean_score_diff - computes mean score difference of player1 compared to player2.

  • mean_score_diff_pos - equivalent to mean_score_diff but returns 0 if result is negative.

  • mean_score - computes mean score of player1.

  • sum_score_diff - computes sum of score differences of player1 compared to player2.

  • sum_score_diff_pos - equivalent to sum_score_diff but returns 0 if result is negative.

  • sum_score - computes sum of scores of player1.

  • num_wins - computes number of matchups player1 scored more than player2. Draws (determined by dplyr::near()) are omitted.

  • num_wins2 - computes number of matchups player1 scored more than player2 plus half the number of matchups where they had draw. Note that for equal player1 and player2 there might be non-zero output.

  • num - computes number of matchups.

Note that it is generally better to subset h2h_funs using names rather than indices because the order of elements might change in future versions.

See also

Long format of Head-to-Head values.

Matrix format of Head-to-Head values.

Examples

ncaa2005 %>% h2h_long(!!!h2h_funs)
#> # A long format of Head-to-Head values: #> # A tibble: 25 x 11 #> player1 player2 mean_score_diff mean_score_diff… mean_score sum_score_diff #> <chr> <chr> <dbl> <dbl> <dbl> <int> #> 1 Duke Duke 0 0 8.75 0 #> 2 Duke Miami -45 0 7 -45 #> 3 Duke UNC -3 0 21 -3 #> 4 Duke UVA -31 0 7 -31 #> 5 Duke VT -45 0 0 -45 #> 6 Miami Duke 45 45 52 45 #> 7 Miami Miami 0 0 34.5 0 #> 8 Miami UNC 18 18 34 18 #> 9 Miami UVA 8 8 25 8 #> 10 Miami VT 20 20 27 20 #> # … with 15 more rows, and 5 more variables: sum_score_diff_pos <dbl>, #> # sum_score <int>, num_wins <dbl>, num_wins2 <dbl>, num <int>
ncaa2005 %>% h2h_mat(!!!h2h_funs["num_wins2"])
#> # A matrix format of Head-to-Head values: #> Duke Miami UNC UVA VT #> Duke 2 0 0 0 0 #> Miami 1 2 1 1 1 #> UNC 1 0 2 1 0 #> UVA 1 0 0 2 0 #> VT 1 0 1 1 2