Create Factor Summary Tables from Bootstrap Results
Source:R/format_subgroup_summary_tables.R
create_factor_summary_tables.RdGenerates formatted GT tables summarizing factor frequencies from bootstrap subgroup analysis. Creates two complementary tables: one showing factor selection frequencies within each position (M.1, M.2, etc.), and another showing overall factor frequencies across all positions.
Arguments
- factor_freq
Data.frame or data.table. Factor frequency table from
summarize_bootstrap_subgroups, containing columns:Position: Position identifier (e.g., "M.1", "M.2")Factor: Factor definition stringN: Count of times factor appeared in this positionPercent: Percentage relative to times position was populated
- n_found
Integer. Number of successful bootstrap iterations (where a subgroup was identified). Used to calculate overall percentages.
- min_percent
Numeric. Minimum percentage threshold for including factors in the tables. Factors with selection frequencies below this threshold are excluded. Default is 2 (i.e., 2%).
Value
A list with up to two GT table objects:
by_positionGT table showing factor frequencies within each position. Percentages represent conditional probability of factor selection given that the position was populated. Within each position, percentages sum to approximately 100% (may not sum exactly to 100% after filtering).
overallGT table showing total factor frequencies across all positions. Includes additional columns indicating which positions each factor appeared in and how many unique positions used the factor. Percentages represent proportion of successful iterations where the factor appeared in any position.
If no factors meet the minimum threshold, the corresponding table element will be NULL.
Note
This function requires the gt package for table creation. The overall table also requires dplyr for data aggregation. If dplyr is not available, only the position-specific table will be created and the overall element will be NULL.
Always check for NULL before using the returned tables:
If all factors have percentages below min_percent, both table elements
will be NULL.
See also
summarize_bootstrap_subgroupsfor generating the factor_freq inputformat_subgroup_summary_tablesfor creating all subgroup summary tablessummarize_bootstrap_resultsfor complete bootstrap analysis workflowforestsearch_bootstrap_dofuturefor running bootstrap analysis