summarise_dt {tidyfst} | R Documentation |
Summarise columns to single values
Description
Summarise group of values into one value for each group. If there is only one group, then only one value would be returned. The summarise function should always return a single value.
Usage
summarise_dt(.data, ..., by = NULL)
summarize_dt(.data, ..., by = NULL)
summarise_when(.data, when, ..., by = NULL)
summarize_when(.data, when, ..., by = NULL)
summarise_vars(.data, .cols = NULL, .func, ..., by)
summarize_vars(.data, .cols = NULL, .func, ..., by)
Arguments
.data |
data.frame |
... |
List of variables or name-value pairs of summary/modifications
functions for |
by |
unquoted name of grouping variable of list of unquoted names of grouping variables. For details see data.table |
when |
An object which can be coerced to logical mode |
.cols |
Columns to be summarised. |
.func |
Function to be run within each column, should return a value or vectors with same length. |
Details
summarise_vars
could complete summarise on specific columns.
Value
data.table
See Also
Examples
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(is.numeric,min,by ="Species")
mtcars %>% summarise_vars(is.numeric,mean,by = c("vs", "am"))
# use multiple functions on multiple columns
iris %>%
summarise_vars(is.numeric,.func = list(mean,sd,median))
iris %>%
summarise_vars(is.numeric,.func = list(mean,sd,median),by = Species)
[Package tidyfst version 1.7.9 Index]