collapse_counts: collapse_counts

View source: R/utils.R

collapse_countsR Documentation

collapse_counts

Description

#' When a grouping variable count_by has more than two levels, this utility collapses all of the level-specific columns

Usage

collapse_counts(df, count_by)

Arguments

df

A data.frame produced by one of the TableSubgroup functions

count_by

A string giving the name of the variable whose per-level count columns should be collapsed. If NULL, df is returned unmodified.

Details

This helper is intended for internal use by TableSubgroupCox(), TableSubgroupMultiCox(), and their GLM equivalents. It simplifies reporting when you request counts stratified by a factor with more than two levels.

Value

A data.frame identical to 'f except that: All Count(count_by=…) columns are removed. A single column Count(by count_by) remains, containing the first non-missing, non-empty value from the original per-level columns.


jstable documentation built on June 8, 2025, 11:13 a.m.