summarize_samples {mildsvm} | R Documentation |
Summarize data across functions
Description
Summarize a numeric data frame based on specified grouping columns and a list
of functions. This is useful in summarizing a mild_df
object from the
sample level to the instance level.
Usage
## Default S3 method:
summarize_samples(data, group_cols, .fns = list(mean = mean), cor = FALSE, ...)
## S3 method for class 'mild_df'
summarize_samples(data, ...)
Arguments
data |
A data.frame, 'mild_df' object, or similar of data to summarize. |
group_cols |
A character vector of column(s) that describe groups to summarize across. |
.fns |
A list of functions (default |
cor |
A logical (default |
... |
Arguments passed to or from other methods. |
Value
A tibble with summarized data. There will be one row for each set
of distinct groups specified by group_cols
. There will be one column for
each of the group_cols
, plus length(.fns)
columns for each of the
features in data
, plus correlation columns if specified.
Methods (by class)
-
default
: Method for data.frame-like objects. -
mild_df
: Method formild_df
objects.
Author(s)
Sean Kent
Examples
fns <- list(mean = mean, sd = sd)
summarize_samples(mtcars, group_cols = c("cyl", "gear"), .fns = fns)
summarize_samples(mtcars, group_cols = c("cyl", "gear"), .fns = fns, cor = TRUE)