tidy_group_by: Group results by selected columns

View source: R/tidy_group_by.R

tidy_group_byR Documentation

Group results by selected columns

Description

Indicates that results should be grouped. By default (group_by = auto_group_by()), results will be grouped according to the y.level column (for multinomial models) or the component column (multi-components models) if any.

Usage

tidy_group_by(
  x,
  group_by = auto_group_by(),
  group_labels = NULL,
  model = tidy_get_model(x)
)

auto_group_by()

Arguments

x

(data.frame)
A tidy tibble as produced by ⁠tidy_*()⁠ functions.

group_by

(tidy-select)
One or several variables to group by. Default is auto_group_by(). Use NULL to force ungrouping.

group_labels

(string)
An optional named vector of custom term labels.

model

(a model object, e.g. glm)
The corresponding model, if not attached to x.

Value

The x tibble with, if relevant, an additional group_by column.

See Also

Other tidy_helpers: tidy_add_coefficients_type(), tidy_add_contrasts(), tidy_add_estimate_to_reference_rows(), tidy_add_header_rows(), tidy_add_n(), tidy_add_pairwise_contrasts(), tidy_add_reference_rows(), tidy_add_term_labels(), tidy_add_variable_labels(), tidy_attach_model(), tidy_disambiguate_terms(), tidy_identify_variables(), tidy_plus_plus(), tidy_remove_intercept(), tidy_select_variables()

Examples


mod <- multinom(Species ~ Petal.Width + Petal.Length, data = iris)
mod |> tidy_and_attach() |> tidy_group_by()

mod |>
  tidy_and_attach() |>
  tidy_group_by(group_labels = c(versicolor = "harlequin blueflag"))

mod |> tidy_and_attach() |> tidy_group_by(group_by = NULL)

mod |>
  tidy_and_attach() |>
  tidy_identify_variables() |>
  tidy_group_by(group_by = variable)


broom.helpers documentation built on April 12, 2025, 2:26 a.m.