item-summary-add: Add item summary to competition results

Description Usage Arguments Details Value See Also Examples

Description

This page describes functions for adding item summary as columns to competition results.

Usage

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

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

add_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

If "game" is present in item but not in column names of cr_data (which can occur in case of widecr format) then every row is treated as separate game results. In all other cases every entry of item should be present in column names of cr_data.

As in item-summary one can control the names of the summaries by adding prefix stored in prefix as extra argument.

Value

add_item_summary returns cr_data with added (by left joining) item summaries.

add_game_summary and add_player_summary are wrappers around add_item_summary with item equals to "game" and "player" accordingly.

See Also

item-summary for description of computing item summary.

item-summary-functions for implemented summary_funs.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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.
add_game_summary(cr_data = cr_data, summary_fun = summary_min_max_score)
add_player_summary(cr_data = cr_data, summary_fun = summary_min_max_score)
add_item_summary(
  cr_data = cr_data, item = c("season", "player"),
  summary_fun = summary_min_max_score
)
add_item_summary(
  cr_data = cr_data, item = c("season", "player"),
  summary_fun = summary_min_max_score, prefix = "seasonPlayer_"
)

# Using without column "game"
cr_data <- to_widecr(data.frame(
  player1 = 1:10, score1 = 10:19,
  player2 = c(2:10, 1), score2 = 11:20
))
add_game_summary(cr_data = cr_data, summary_fun = summary_min_max_score)

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