summarise_dt: Summarise columns to single values

Description Usage Arguments Value See Also Examples

View source: R/summarise_dt.R

Description

Analogous function for summarise in dplyr.

Usage

1
2
3

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

Value

data.table

See Also

summarise

Examples

1
2
3
4
5
6
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

hope-data-science/tidydt documentation built on Feb. 21, 2020, 10:25 a.m.