Skip to contents

Removes the header, reference, missing-value or level rows of the selected variables from a table.

Usage

remove_row_type(
  x,
  variables = everything(),
  type = c("header", "reference", "missing", "level", "all"),
  level_value = NULL
)

Arguments

x

(ltsummary)
An ltsummary object.

variables

(selector)
Variables to remove rows from. Default is everything().

type

(string)
The type of row to remove, one of c("header", "reference", "missing", "level", "all"). The header row is the variable label row of categorical and "continuous2" variables; reference rows belong to regression tables.

level_value

(string)
With type = "level", the character value of the level to remove. When NULL, all levels are removed.

Value

An ltsummary object.

Examples

# Example 1 ----------------------------------
# drop the label row of a categorical variable whose levels speak for themselves
trial$age60 <- ifelse(trial$age < 60, "<60", "60+")
trial |>
  tbl_summary(by = trt, missing = "no", include = c(trt, age, age60)) |>
  remove_row_type(age60, type = "header")
# Example 2 ---------------------------------- # drop the missing-value rows trial |> tbl_summary(include = c(age, marker, response)) |> remove_row_type(type = "missing")
# Example 3 ---------------------------------- # drop one level trial |> tbl_summary(include = response, type = response ~ "categorical") |> remove_row_type(response, type = "level", level_value = "0")