Learn R Programming

tern (version 0.9.8)

add_rowcounts: Layout-creating function to add row total counts

Description

[Stable]

This works analogously to rtables::add_colcounts() but on the rows. This function is a wrapper for rtables::summarize_row_groups().

Usage

add_rowcounts(lyt, alt_counts = FALSE)

Value

A modified layout where the latest row split labels now have the row-wise total counts (i.e. without column-based subsetting) attached in parentheses.

Arguments

lyt

(PreDataTableLayouts)
layout that analyses will be added to.

alt_counts

(flag)
whether row counts should be taken from alt_counts_df (TRUE) or from df (FALSE). Defaults to FALSE.

Examples

Run this code
basic_table() %>%
  split_cols_by("ARM") %>%
  add_colcounts() %>%
  split_rows_by("RACE", split_fun = drop_split_levels) %>%
  add_rowcounts() %>%
  analyze("AGE", afun = list_wrap_x(summary), format = "xx.xx") %>%
  build_table(DM)

Run the code above in your browser using DataLab