Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ggforestplotR
Title: Publication-Ready Forest Plots with 'ggplot2'
Version: 0.5.0
Version: 0.5.0.9000
Authors@R:
person(given = "Carson",
family = "Richardson",
Expand Down Expand Up @@ -35,4 +35,4 @@ Config/testthat/edition: 3
Config/Needs/website: pkgdown
URL: https://thatoneguy006.github.io/ggforestplotR/, https://github.com/thatoneguy006/ggforestplotR
BugReports: https://github.com/thatoneguy006/ggforestplotR/issues
Config/roxygen2/version: 8.0.0
Config/roxygen2/version: 8.1.0
96 changes: 67 additions & 29 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# ggforestplotR (development version)

- Added semantic forest row types (`estimate`, `reference`, `header`, `summary`,
and `spacer`) so tables can contain reference categories and structural rows
without fabricated plot geometry.
- Added vectorized `formatters` to both table helpers for estimates, confidence
bounds, p-values, and preserved source columns. Digit settings and text
templates remain available.
- Added `reference_text` to both table helpers to customize reference cells.

# ggforestplotR 0.5.0

## Breaking Changes
Expand All @@ -12,7 +22,7 @@
- Added explicit `subgroup` mappings for mixed hierarchical displays, allowing
standalone covariates and categorical subgroups to share a forest
plot. Subgroup p-values can be delegated as "overall" or "level" via `p_method`
in `tidy_forest_model()`.
in `tidy_forest_model()` (#11)
- Added covariance-aware subgroup effects for fitted interaction models.
`tidy_forest_model()` and fitted-model `as_forest_data()` methods now use
`marginaleffects` to derive average slopes or comparisons from the original
Expand All @@ -37,10 +47,10 @@

- Added the `forest_data` S3 class as the package's stable interchange format.
It stores validated effect-scale, axis, confidence-level, reference-value,
source-model, source-package, and source-column metadata.
source-model, source-package, and source-column metadata. (#17)
- Converted `as_forest_data()` into an S3 generic with methods for data frames,
existing `forest_data` objects, linear and generalized linear models, Cox
models, and supported mixed-model classes.
models, and supported mixed-model classes. (#19)
- Refactored `ggforestplot()` to consume the `forest_data` contract instead of
determining plotting behavior from the original model class.
- Added `forest_metadata()` for inspecting the semantic and provenance
Expand Down Expand Up @@ -92,12 +102,12 @@

- Added mixed-model support for `tidy_forest_model()` and `ggforestplot()`
when `broom.mixed` is installed. Mixed-model tidiers are restricted to fixed
effects so random-effect parameter rows are not plotted as terms.
effects so random-effect parameter rows are not plotted as terms. (#21)
- Added confidence interval truncation support to `ggforestplot()` via
`ci_limits`, with optional arrowheads for intervals extending beyond the
displayed range.
displayed range. (#18)
- Added `bind_forest_models()` to stack multiple fitted models into one
grouped forest-plot data frame.
grouped forest-plot data frame. (#16)

## Minor Changes

Expand All @@ -112,59 +122,87 @@
- Faceted `ggforestplot()` output now respects factor level order in the
`facet` column, allowing users to control facet ordering directly from their
data.
- Fixed faceted `ggforestplot()` output when users add `scale_y_discrete(limits = ...)`, preserving per-facet row filtering while accepting visible term labels.
- Fixed faceted `ggforestplot()` output when users add
`scale_y_discrete(limits = ...)`, preserving per-facet row filtering while
accepting visible term labels. (#20)

# ggforestplotR 0.2.1

## Breaking Changes

- Simplified the reference-line API in `ggforestplot()`: `ref_line` now takes the numeric reference value directly, and `NULL` hides the line.
- Replaced the older reference-line arguments with `ref_label`, `ref_linetype`, and `ref_color`.
- Simplified the reference-line API in `ggforestplot()`: `ref_line` now takes
the numeric reference value directly, and `NULL` hides the line.
- Replaced the older reference-line arguments with `ref_label`, `ref_linetype`,
and `ref_color`.

## Major Changes

- Added `facet` and `facet_strip_position` as clearer names for grouped plot panels. The older `grouping` and `grouping_strip_position` arguments now warn and continue to work.
- Added `linewidth` for confidence interval widths. The older `line_size` argument now warns and continues to work.
- Added deprecation warnings for table-display shortcuts in favor of explicit `columns`, `left_columns`, and `right_columns` selections.
- Added `facet` and `facet_strip_position` as clearer names for grouped plot
panels. The older `grouping` and `grouping_strip_position` arguments now warn
and continue to work.
- Added `linewidth` for confidence interval widths. The older `line_size`
argument now warns and continues to work.
- Added deprecation warnings for table-display shortcuts in favor of explicit
`columns`, `left_columns`, and `right_columns` selections.

## Minor Changes

- Added `stripe_alpha` to control row stripe transparency across plots, side tables, and split tables.
- Updated table helpers so they inherit custom y-axis ordering and filtering from the trained forest plot scale.
- Updated vignettes and tests to use the clearer faceting and geometry argument names.
- Added `stripe_alpha` to control row stripe transparency across plots,
side tables, and split tables. (#7)
- Updated table helpers so they inherit custom y-axis ordering and filtering
from the trained forest plot scale. (#9)
- Updated vignettes and tests to use the clearer faceting and geometry argument
names.

# ggforestplotR 0.2.0

## Major Changes

- Added separate table formatting controls for point estimates, confidence interval bounds, and p-values via `estimate_digits`, `interval_digits`, and `p_digits`.
- Added `ref_line`, `ref_line_value`, and `ref_line_label` to standardize reference-line naming while keeping `zero_line` arguments backward compatible.
- Added separate table formatting controls for point estimates,
confidence interval bounds, and p-values via `estimate_digits`,
`interval_digits`, and `p_digits`.
- Added `ref_line`, `ref_line_value`, and `ref_line_label` to standardize
reference-line naming while keeping `zero_line` arguments backward compatible.
- Added `term_labels`, a named-vector relabeling helper for displayed model terms.
- Expanded `add_forest_table(columns = ...)` and split-table column selection to support arbitrary preserved data columns in addition to built-in columns.
- Added `column_labels`, a named-vector helper for relabeling displayed table column headers.
- Added a built-in `ci` table column and `ci_fmt` so users can display point estimates and confidence intervals in separate columns. `conf.low` and `conf.high` are accepted as aliases for `ci`.
- Expanded `add_forest_table(columns = ...)` and split-table column selection to
support arbitrary preserved data columns in addition to built-in columns.
- Added `column_labels`, a named-vector helper for relabeling displayed table
column headers.
- Added a built-in `ci` table column and `ci_fmt` so users can display point
estimates and confidence intervals in separate columns. `conf.low` and
`conf.high` are accepted as aliases for `ci`.

## Minor Changes

- Added model-aware default effect labels and scales, including odds ratios for binomial logit models and hazard ratios for Cox models.
- Added model-aware default effect labels and scales, including odds ratios for
binomial logit models and hazard ratios for Cox models.

# ggforestplotR 0.1.1

## Minor Changes

- Added `events` column support across `ggforestplot()`, `as_forest_data()`, `add_forest_table()`, and `add_split_table()`. (Thanks @sritchie73 for the suggestion)
- Added table header styling controls for font size, font face, and font family in both table helpers. (Thanks @sritchie73 for the suggestion)
- Split table composition code into dedicated source files to simplify maintenance of the public API.
- Refined split-table examples and documentation to match the expanded numeric column mapping.
- Added `events` column support across `ggforestplot()`, `as_forest_data()`,
`add_forest_table()`, and `add_split_table()`. (#2) (#3)
(Thanks @sritchie73 for the suggestion)
- Added table header styling controls for font size, font face, and font family
in both table helpers. (Thanks @sritchie73 for the suggestion)
- Split table composition code into dedicated source files to simplify
maintenance of the public API.
- Refined split-table examples and documentation to match the expanded numeric
column mapping.

# ggforestplotR 0.1.0

## Major Changes

- Refined split-table layout logic, including dynamic panel widths from column counts, alignment controls, and cleaner stripe/background handling.
- `add_forest_table()` now allows for custom column ordering via the `columns` argument.
- Converted package documentation to roxygen-generated `NAMESPACE` and `.Rd` files.
- Reworked package documentation, including pkgdown configuration, README installation guidance, and the vignette set.
- Refined split-table layout logic, including dynamic panel widths from column
counts, alignment controls, and cleaner stripe/background handling.
- `add_forest_table()` now allows for custom column ordering via the `columns`
argument.
- Converted package documentation to roxygen-generated `NAMESPACE` and `.Rd`
files.
- Reworked package documentation, including pkgdown configuration, README
installation guidance, and the vignette set.

# ggforestplotR 0.0.0.9000

Expand Down
17 changes: 17 additions & 0 deletions R/add_forest_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
p_digits = NULL,
estimate_fmt = NULL,
ci_fmt = NULL,
formatters = NULL,
reference_text = "Reference",
text_size = NULL,
header_text_size = NULL,
header_fontface = "bold",
Expand Down Expand Up @@ -140,6 +142,8 @@
p_digits = digits$p_digits,
estimate_fmt = estimate_fmt,
ci_fmt = ci_fmt,
formatters = formatters,
reference_text = reference_text,
columns = table_columns,
display_data = display_data
)
Expand Down Expand Up @@ -251,6 +255,13 @@
#' `columns` includes `"ci"`. Use `{conf.low}` and `{conf.high}` as
#' placeholders. The shorthand `{conf.low, conf.high}` is also supported.
#' Defaults to `"({conf.low}, {conf.high})"`.
#' @param formatters Named list of vectorized functions for scalar table
#' values. Keys include `estimate`, `ci`, `conf.low`, `conf.high`, `p`
#' (or `p.value`), `n`, `events`, `group`, and preserved source columns.
#' Each function receives a vector and returns one value per input.
#' Functions take precedence over digit settings; `estimate_fmt` and
#' `ci_fmt` compose the resulting strings.
#' @param reference_text Text shown in estimate cells for reference rows.
#' @param text_size Text size for table contents. Defaults to `3.2`.
#' @param header_text_size Header text size for table column labels. Defaults
#' to `11`.
Expand Down Expand Up @@ -317,6 +328,8 @@ add_forest_table <- function(plot = NULL,
p_digits = NULL,
estimate_fmt = NULL,
ci_fmt = NULL,
formatters = NULL,
reference_text = "Reference",
text_size = NULL,
header_text_size = NULL,
header_fontface = "bold",
Expand Down Expand Up @@ -361,6 +374,8 @@ add_forest_table <- function(plot = NULL,
p_digits = p_digits,
estimate_fmt = estimate_fmt,
ci_fmt = ci_fmt,
formatters = formatters,
reference_text = reference_text,
text_size = text_size,
header_text_size = header_text_size,
header_fontface = header_fontface,
Expand Down Expand Up @@ -396,6 +411,8 @@ add_forest_table <- function(plot = NULL,
p_digits = p_digits,
estimate_fmt = estimate_fmt,
ci_fmt = ci_fmt,
formatters = formatters,
reference_text = reference_text,
text_size = text_size,
header_text_size = header_text_size,
header_fontface = header_fontface,
Expand Down
18 changes: 18 additions & 0 deletions R/add_split_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
p_digits = NULL,
estimate_fmt = NULL,
ci_fmt = NULL,
formatters = NULL,
reference_text = "Reference",
text_size = NULL,
header_text_size = NULL,
header_fontface = "bold",
Expand Down Expand Up @@ -144,6 +146,8 @@
p_digits = digits$p_digits,
estimate_fmt = estimate_fmt,
ci_fmt = ci_fmt,
formatters = formatters,
reference_text = reference_text,
columns = resolved_left,
display_data = display_data
)
Expand All @@ -161,6 +165,8 @@
p_digits = digits$p_digits,
estimate_fmt = estimate_fmt,
ci_fmt = ci_fmt,
formatters = formatters,
reference_text = reference_text,
columns = resolved_right,
display_data = display_data
)
Expand Down Expand Up @@ -329,6 +335,12 @@
#' table columns include `"ci"`. Use `{conf.low}` and `{conf.high}` as
#' placeholders. The shorthand `{conf.low, conf.high}` is also supported.
#' Defaults to `"({conf.low}, {conf.high})"`.
#' @param formatters Named list of vectorized functions for scalar table
#' values. Keys include `estimate`, `ci`, `conf.low`, `conf.high`, `p`
#' (or `p.value`), `n`, `events`, `group`, and preserved source columns.
#' Functions take precedence over digit settings; `estimate_fmt` and
#' `ci_fmt` compose the resulting strings.
#' @param reference_text Text shown in estimate cells for reference rows.
#' @param text_size Text size for table contents. Defaults to `3.2`.
#' @param header_text_size Header text size for table column labels. Defaults
#' to `11`.
Expand Down Expand Up @@ -396,6 +408,8 @@ add_split_table <- function(plot = NULL,
p_digits = NULL,
estimate_fmt = NULL,
ci_fmt = NULL,
formatters = NULL,
reference_text = "Reference",
text_size = NULL,
header_text_size = NULL,
header_fontface = "bold",
Expand Down Expand Up @@ -435,6 +449,8 @@ add_split_table <- function(plot = NULL,
p_digits = p_digits,
estimate_fmt = estimate_fmt,
ci_fmt = ci_fmt,
formatters = formatters,
reference_text = reference_text,
text_size = text_size,
header_text_size = header_text_size,
header_fontface = header_fontface,
Expand Down Expand Up @@ -467,6 +483,8 @@ add_split_table <- function(plot = NULL,
p_digits = p_digits,
estimate_fmt = estimate_fmt,
ci_fmt = ci_fmt,
formatters = formatters,
reference_text = reference_text,
text_size = text_size,
header_text_size = header_text_size,
header_fontface = header_fontface,
Expand Down
17 changes: 17 additions & 0 deletions R/as_forest_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
#' @param term_labels Optional named vector used to relabel displayed terms.
#' Names should match values in the term column and values are the labels to
#' display.
#' @param row_type Optional column name defining semantic rows: `"estimate"`,
#' `"reference"`, `"header"`, `"summary"`, or `"spacer"`. Estimate and
#' summary rows require finite estimate and CI values; other rows require
#' missing geometry. Structured rows retain source order, so use
#' `sort_terms = "none"`. If omitted, all rows are estimates.
#' @param group Optional column name used for color-grouping multiple
#' estimates per row. If this column is a factor, its levels control the
#' group legend and vertical dodge order.
Expand Down Expand Up @@ -122,6 +127,9 @@ as_forest_data.forest_data <- function(data,
if (!"label" %in% names(out)) {
out$label <- out$term
}
if (!"row_type" %in% names(out)) {
out$row_type <- rep("estimate", nrow(out))
}
if (!is.null(p_method)) {
stop(
"`p_method` is already defined by the `forest_data` metadata.",
Expand Down Expand Up @@ -188,6 +196,7 @@ as_forest_data.data.frame <- function(data,
sort_terms = c("none", "descending", "ascending"),
subgroup = NULL,
p_method = c("overall", "level"),
row_type = NULL,
...) {
if (!inherits(data, "data.frame")) {
stop(
Expand Down Expand Up @@ -239,6 +248,7 @@ as_forest_data.data.frame <- function(data,
conf.low = resolve_column(data, conf.low, "conf.low"),
conf.high = resolve_column(data, conf.high, "conf.high"),
label = resolve_column(data, label, "label", required = FALSE),
row_type = resolve_column(data, row_type, "row_type", required = FALSE),
group = resolve_column(data, group, "group", required = FALSE),
subgroup = resolve_column(data, subgroup, "subgroup", required = FALSE),
grouping = resolve_column(data, grouping, "grouping", required = FALSE),
Expand Down Expand Up @@ -269,6 +279,13 @@ as_forest_data.data.frame <- function(data,
as.character(data[[cols$label]])
}
out$label <- apply_term_labels(out$term, out$label, term_labels)
out$row_type <- if (is.null(cols$row_type)) {
rep("estimate", nrow(out))
} else {
normalize_forest_row_type(data[[cols$row_type]])
}
out$term[out$row_type == "spacer" & is.na(out$term)] <- ""
out$label[out$row_type == "spacer" & is.na(out$label)] <- ""

out$group <- if (is.null(cols$group)) {
NA_character_
Expand Down
Loading
Loading