summarize {ir}R Documentation

Summarize each group in a ir object to fewer rows

Description

Summarize each group in a ir object to fewer rows

Usage

summarize.ir(.data, ..., .groups = NULL)

summarise.ir(.data, ..., .groups = NULL)

Arguments

.data

An object of class ir.

...

<data-masking> Name-value pairs of summary functions. The name will be the name of the variable in the result.

The value can be:

  • A vector of length 1, e.g. min(x), n(), or sum(is.na(y)).

  • A vector of length n, e.g. quantile().

  • A data frame, to add multiple columns from a single expression.

.groups

[Experimental] Grouping structure of the result.

  • "drop_last": dropping the last level of grouping. This was the only supported option before version 1.0.0.

  • "drop": All levels of grouping are dropped.

  • "keep": Same grouping structure as .data.

  • "rowwise": Each row is its own group.

When .groups is not specified, it is chosen based on the number of rows of the results:

  • If all the results have 1 row, you get "drop_last".

  • If the number of rows varies, you get "keep".

In addition, a message informs you of that choice, unless the result is ungrouped, the option "dplyr.summarise.inform" is set to FALSE, or when summarise() is called from a function in a package.

Value

.data with summarized columns. If the spectra column is dropped or invalidated (see ir_new_ir()), the ir class is dropped, else the object is of class ir.

Source

dplyr::summarize()

See Also

Other tidyverse: arrange.ir(), distinct.ir(), extract.ir(), filter-joins, filter.ir(), group_by, mutate-joins, mutate, nest, pivot_longer.ir(), pivot_wider.ir(), rename, rowwise.ir(), select.ir(), separate.ir(), separate_rows.ir(), slice, unite.ir()

Examples

## summarize

# select in each sample_type groups the first spectrum
ir_sample_data %>%
  dplyr::group_by(sample_type) %>%
  dplyr::summarize(spectra = spectra[[1]])



[Package ir version 0.2.1 Index]