Learn R Programming

mildsvm (version 0.4.1)

summarize_samples: 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

# S3 method for default
summarize_samples(data, group_cols, .fns = list(mean = mean), cor = FALSE, ...)

# S3 method for mild_df summarize_samples(data, ...)

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.

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 list(mean = mean)).

cor

A logical (default FALSE) for whether to include correlations between all features in the summarization.

...

Arguments passed to or from other methods.

Methods (by class)

  • summarize_samples(default): Method for data.frame-like objects.

  • summarize_samples(mild_df): Method for mild_df objects.

Author

Sean Kent

Examples

Run this code
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)

Run the code above in your browser using DataLab