View source: R/format_subgroup_summary_tables.R
| create_factor_summary_tables | R Documentation |
Generates 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.
create_factor_summary_tables(factor_freq, n_found, min_percent = 2)
factor_freq |
Data.frame or data.table. Factor frequency table from
|
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%). |
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.
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 (!is.null(factor_tables$by_position)) {
print(factor_tables$by_position)
}
If all factors have percentages below min_percent, both table elements
will be NULL.
summarize_bootstrap_subgroups for generating the factor_freq input
format_subgroup_summary_tables for creating all subgroup summary tables
summarize_bootstrap_results for complete bootstrap analysis workflow
forestsearch_bootstrap_dofuture for running bootstrap analysis
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.