summarise_dt: Summarise columns to single values

Description Usage Arguments Value See Also Examples

Description

Analogous function for summarise and summarise_all in dplyr.

Usage

1
2
3
4
5
6
7
summarise_dt(data, ..., by, keyby, fun = NULL)

summarize_dt(data, ..., by, keyby, fun = NULL)

summarise_all_dt(data, fun, by, keyby)

summarize_all_dt(data, fun, by, keyby)

Arguments

data

data.frame

...

List of variables or name-value pairs of summary/modifications functions.

by

unquoted name of grouping variable of list of unquoted names of grouping variables. For details see data.table

keyby

Same as by, but with an additional setkey() run on the by columns of the result, for convenience. It is common practice to use 'keyby=' routinely when you wish the result to be sorted. For details see data.table.

fun

function which will be applied to all variables in dt_summarize and dt_summarize_all.

Value

data.table

See Also

summarise,dt_summarise, summarise_all,dt_summarise_all

Examples

1
2
3
4
5
6
7
8
iris %>% summarise_dt(avg = mean(Sepal.Length))
iris %>% summarise_dt(avg = mean(Sepal.Length),by = Species)
mtcars %>% summarise_dt(avg = mean(hp),by = .(cyl,vs))

# the data.table way
mtcars %>% summarise_dt(cyl_n = .N, by = .(cyl, vs)) # `.`` is short for list

iris %>%summarise_all_dt(fun = mean,by = Species)

hope-data-science/tidydt0 documentation built on Feb. 3, 2020, 12:04 a.m.