Learn R Programming

tidyfst (version 0.9.3)

summarise_dt: Summarise columns to single values

Description

Analogous function for summarise in dplyr.

Usage

summarise_dt(.data, ..., by = NULL)

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

summarise_vars(.data, .cols = NULL, .func, ...)

summarize_vars(.data, .cols = NULL, .func, ...)

Arguments

.data

data.frame

...

List of variables or name-value pairs of summary/modifications functions for summarise_dt.Additional parameters to be passed to parameter '.func' in summarise_vars.

by

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

.cols

Columns to be summarised.

.func

Function to be run within each column, should return a value or vectors with same length.

Value

data.table

Details

summarise_vars could complete summarise on specific columns.

See Also

summarise

Examples

Run this code
# NOT RUN {
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_vars(is.numeric,min)
iris %>% summarise_vars(-is.factor,min)
iris %>% summarise_vars(1:4,min)
iris %>% summarise_vars(.func = as.character)
# }

Run the code above in your browser using DataLab