item-summary: Compute item summary

Description Usage Arguments Details Value See Also Examples

Description

This page describes functionality for computing item summary, i.e. some summary measurements (of arbitrary nature) of item (one or more columns) present in competition results.

Usage

1
2
3
4
5
get_item_summary(cr_data, item, summary_fun = NULL, ...)

get_game_summary(cr_data, summary_fun = NULL, ...)

get_player_summary(cr_data, summary_fun = NULL, ...)

Arguments

cr_data

Competition results in format ready for to_longcr.

item

Character vector of columns to group by.

summary_fun

Function to compute item summary (see Details).

...

Additional arguments to be passed to or from methods.

Details

Argument item defines on which columns grouping is made for computing item summary. Basically get_item_summary applies summary_fun to groups of cr_data defined by item.

summary_fun is a function that takes competition results of a particular item (game, player, their combination, etc.) and produces named vector of item summary. Also it should take prefix and ... as argument for easier use. See item-summary-functions for more details.

One can control the names of the summaries by adding prefix stored in prefix as extra argument.

Value

If summary_fun is NULL then get_item_summary returns a tibble with columns named as stored in argument item and which has all unique values of particular item in cr_data. If not NULL then there will be extra columns for every summary value that summary_fun produces.

get_game_summary and get_player_summary are wrappers around get_item_summary with item equals to "game" and "player" accordingly.

See Also

item-summary-functions for implemented summary_funs.

item-summary-add for adding item summary to competition results.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
cr_data <- data.frame(
  game = rep(1:20, each = 2),
  player = rep(1:10, times = 4),
  score = 31:70,
  season = rep(1:2, each = 20)
)

# Computing summaries.
get_game_summary(cr_data = cr_data, summary_fun = summary_min_max_score)
get_player_summary(cr_data = cr_data, summary_fun = summary_min_max_score)
get_item_summary(
  cr_data = cr_data, item = c("season", "player"),
  summary_fun = summary_min_max_score
)

# Varying prefix of the summary columns.
get_item_summary(
  cr_data = cr_data, item = c("season", "player"),
  summary_fun = summary_mean_sd_score, prefix = "seasonPlayer_"
)

echasnovski/comperes documentation built on June 21, 2017, 1:17 a.m.