condense: Condense two or three columns into one

View source: R/condense.R

condenseR Documentation

Condense two or three columns into one

Description

Useful for saving space with summary tables created by continuous_table(), discrete_table(), ticked_table() or ae_table().

Usage

condense(
  df,
  first_col = variable,
  second_col = scoring,
  third_col,
  hline = TRUE,
  double.header = TRUE,
  indent = "quad"
)

Arguments

df

a data frame containing at least one column with repeated values.

first_col

variable name of the column to collapse into - should contain repeated values. Default is variable for quick use with the summary table functions.

second_col

variable name of the column to be collapsed into first_col. Default is scoring for quick use with the summary table functions.

third_col

Optionally, a third column to be collapsed into second_col.

hline

Logical indicating whether "\\hline\n" should be added at the start of each unique value in first_col. For use with xtable::xtable(). Default is TRUE.

double.header

Logical indicating whether df has a double header. Default is TRUE.

indent

Character indicating the type of indent to use (the default is "quad"):

  • "quad" uses \LaTeX's ⁠\\quad⁠ to indent the second column (and ⁠\\qquad \\quad⁠ to indent the third column if given)

  • "hang" uses \LaTeX's ⁠\\hangindent2em\\hangafter0⁠ to indent the second column (and ⁠\\hangindent4em\\hangafter0⁠ to indent the third column if given)

  • "space" uses " " to indent the second column (and " " to indent the third column if given)

Examples

  continuous_table(df = iris, Petal.Length, Petal.Width, group = Species) %>%
       condense()


EstherHerbert/Useful.functions documentation built on June 11, 2025, 11:19 p.m.