Skip to contents

This function makes it easier to see which units or records are associated with a particular level of factor. The arguments closely follow tidyr::pivot_wider(), but the major difference is that it is aware of the relationships between columns and makes use of this to present to you information without unnecessary duplication.

Usage

pivot_wider_by(
  data,
  id_cols = NULL,
  id_expand = FALSE,
  names_from = where(is_trt),
  names_prefix = "",
  names_sep = ":",
  names_glue = NULL,
  names_sort = FALSE,
  names_vary = "fastest",
  names_expand = FALSE,
  names_repair = "check_unique",
  values_from = NULL,
  values_fill = NULL,
  values_fn = NULL
)

Arguments

data

An edibble table

id_cols

Columns in the data where the levels correspond to a unique level on the row.

id_expand

If multiple columns are selected, whether all combinations of the levels should be taken into account.

names_from

An expression specifying which columns to pivot from.

names_prefix

A prefix to add to the resulting column names.

names_sep

A separator to use between column names in the resulting wide format.

names_glue

A glue specification to control column names.

names_sort

A logical indicating whether to sort the resulting column names.

names_vary

A character vector of options to specify how to handle varying identifiers.

names_expand

A logical indicating whether to expand identifiers in the column names.

names_repair

A method to handle non-unique resulting column names.

values_from

A character vector specifying columns to use as values in the wide format.

values_fill

A value or function to fill missing values.

values_fn

A function to aggregate values.

See also