summarise_dt | R Documentation |
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.
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)
.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. |
summarise_vars
could complete summarise on specific columns.
data.table
summarise
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.