Functions for computing item summary, i.e. some summary measurements (of arbitrary nature) of item (one or more columns) present in data frame.

summarise_item(tbl, item, ..., .prefix = "")

summarise_game(tbl, ..., .prefix = "")

summarise_player(tbl, ..., .prefix = "")

summarize_item(tbl, item, ..., .prefix = "")

summarize_game(tbl, ..., .prefix = "")

summarize_player(tbl, ..., .prefix = "")

Arguments

tbl

Data frame.

item

Character vector of columns to group by.

...

Name-value pairs of summary functions (as in dplyr::summarise).

.prefix

A string to be added to all summary functions' names.

Value

Output of summarise() as not grouped tibble.

Details

Basically, summarise_item() performs the following steps:

  • Group tbl by columns stored in item. Note that starting from 0.8.0 version of dplyr this might give a warning in case of implicit NAs in factor columns (NA present in column values but not in its levels) suggesting to add NA to levels.

  • Apply dplyr's summarise().

  • Ungroup result.

  • Convert to tibble.

  • Add .prefix to names of summary functions.

summarise_game() and summarise_player() are wrappers for summarise_item() using item = "game" and item = "player" respectively.

See also

Common item summary functions for competition results.

Join item summary

Examples

ncaa2005 %>% dplyr::mutate(game_type = game %% 2) %>% summarise_item(c("game_type", "player"), mean_score = mean(score))
#> # A tibble: 10 x 3 #> game_type player mean_score #> <dbl> <chr> <dbl> #> 1 0 Duke 10.5 #> 2 0 Miami 25 #> 3 0 UNC 15.5 #> 4 0 UVA 12 #> 5 0 VT 48.5 #> 6 1 Duke 7 #> 7 1 Miami 37.7 #> 8 1 UNC 9.5 #> 9 1 UVA 38 #> 10 1 VT 18.5
ncaa2005 %>% summarise_game(mean_score = mean(score), min_score = min(score))
#> # A tibble: 10 x 3 #> game mean_score min_score #> <int> <dbl> <int> #> 1 1 29.5 7 #> 2 2 22.5 21 #> 3 3 22.5 7 #> 4 4 22.5 0 #> 5 5 25 16 #> 6 6 21 17 #> 7 7 17 7 #> 8 8 6 5 #> 9 9 16.5 3 #> 10 10 33 14