Skip to content

Develop#74

Merged
gforge merged 5 commits intomasterfrom
develop
Mar 3, 2026
Merged

Develop#74
gforge merged 5 commits intomasterfrom
develop

Conversation

@gforge
Copy link
Owner

@gforge gforge commented Mar 3, 2026

This pull request introduces version 3.2.0 of the forestplot package, adding several new features, helpers, and improvements focused on label handling, selector-style post-processing, and data documentation. It also refactors internal code for clarity and extensibility, especially around grouped data and plotting logic.

New features and helpers

  • Added new helpers: fp_span(), fp_extract_labeltext(), fp_align_where(), fp_txt_where(), fp_span_where(), fp_set_summary(), and fp_set_favors(), enabling advanced label spanning, extraction, targeted styling, and summary/favors row setting for gforge_forestplot objects. These helpers allow more flexible and expressive forest plot customization. [1] [2]
  • Internal label handling now supports grid grobs and other non-atomic objects in labeltext, preventing coercion errors and allowing direct rendering of complex content in table cells.

Data documentation and structure

  • Improved and relocated documentation for example datasets (HRQoL, dfHRQoL, and inventors_vs_mello) to R/data-descriptions.R, with detailed format, source, and usage examples. This clarifies the structure and intended use for users and developers. [1] [2]

Selector-style and grouped data improvements

  • Refactored grouped data handling in forestplot.grouped_df, introducing fpGetVaryingGroups() for robust group extraction and improved error handling. Also added logic to capture tidy column names for estimates in both grouped and ungrouped data, facilitating downstream processing and reproducibility. [1] [2] [3] [4] [5] [6]

Plotting and internal code cleanup

  • Refactored drawForestplotObject to consistently use named arguments and improved readability, especially for plotting, label, and legend preparation. Added logic to adjust axis layout height when favors text/arrows are positioned outside the plot. [1] [2] [3] [4] [5]
  • Standardized default colgap handling in forestplot.default for more predictable column spacing.

Other updates

  • Bumped package version to 3.2.0 and updated CRAN submission metadata. Enabled LazyData for efficient example dataset loading. [1] [2] [3]

These changes collectively enhance the flexibility, usability, and robustness of the forestplot package for both basic and advanced plotting scenarios.

gforge added 3 commits March 2, 2026 20:30
- Introduced `fp_txt_where` function for selector-based text styling in forest plots.
- Added `inventors_vs_mello` dataset for demonstration purposes.
- Enhanced documentation for `prFpFetchRowLabel` and `text_styling` functions.
- Improved data generation logic in `make_forest_metadata_inventors_vs_mello`.
- Added visual regression tests for column spanning and selector-based styling.
- Implemented tests for label extraction and insertion functionalities.
- Updated vignettes to include examples of new features and improved workflows.
- Introduced `fp_set_favors()` function to add left/right interpretation labels around the x-axis.
- Updated `prFpGetGraphTicksAndClips` and `plot.forestplot_xaxis` to handle new favors indicators.
- Added examples and documentation for `fp_set_favors()`.
- Created tests for `fp_set_favors()` to validate functionality and argument handling.
- Updated vignettes to demonstrate the use of favors indicators in forest plots.
Copilot AI review requested due to automatic review settings March 3, 2026 20:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR releases forestplot v3.2.0, expanding label handling and post-processing capabilities (spanning, selector-style styling, label extraction), improving grouped-data plumbing, and updating documentation/examples (including a new simulated dataset).

Changes:

  • Added label helpers for spanning (fp_span()), selector-based styling (fp_align_where(), fp_txt_where(), fp_span_where()), label extraction (fp_extract_labeltext(), fp_extract_labels()), and summary/favors helpers (fp_set_summary(), fp_set_favors()).
  • Extended label rendering to tolerate non-atomic objects (notably grid grobs) in labeltext, and implemented span-aware label printing.
  • Updated vignettes, examples, tests, NEWS/versioning, and dataset documentation; added inventors_vs_mello data + docs and enabled LazyData.

Reviewed changes

Copilot reviewed 53 out of 55 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
vignettes/forestplot.Rmd Adds extended examples demonstrating spanning, extraction, selector styling, and favors indicators.
tests/testthat/test-span.R New unit tests for fp_span() and grob-in-labeltext support.
tests/testthat/test-selector-styling.R New unit tests for selector-based styling helpers and fp_set_summary().
tests/testthat/test-insert_row.R Extends row/header manipulation tests to cover spanned headers and collisions.
tests/testthat/test-fp_add_favors.R New tests for fp_set_favors() storage/validation/rendering.
tests/testthat/test-extract-labeltext.R New tests for fp_extract_labeltext() / fp_extract_labels() behavior.
tests/forestplot2_vtests.R Adds a visual regression exercise for column spanning; minor formatting changes.
tests/data_generator.R Adds generator for the new inventors_vs_mello example dataset.
man/text_styling.Rd Documents fp_span() in the text styling help page.
man/style_manipulation.Rd Adds fp_set_favors() to related-function lists.
man/row_manipulation.Rd Adds fp_set_favors() to related-function lists.
man/prFpFetchRowLabel.Rd Documents that label cells may be grid grobs.
man/inventors_vs_mello.Rd New Rd for the inventors_vs_mello dataset.
man/fp_txt_where.Rd New Rd for selector-based text gp helper.
man/fp_span_where.Rd New Rd for selector-based spanning helper.
man/fp_set_zebra_style.Rd Adds fp_set_favors() to related-function lists.
man/fp_set_summary.Rd New Rd for selector-based summary row helper.
man/fp_set_favors.Rd New Rd for favors indicators helper.
man/fp_extract_labeltext.Rd New Rd for extracting labeltext columns from data frames.
man/fp_extract_labels.Rd New Rd for rebuilding labels from stored source data.
man/fp_decorate_graph.Rd Adds fp_set_favors() to related-function lists.
man/fp_align_where.Rd New Rd for selector-based alignment helper.
man/fp_add_lines.Rd Adds fp_set_favors() to related-function lists.
man/fpShapesGp.Rd Adds fp_set_favors() to related-function lists.
man/fpLegend.Rd Adds fp_set_favors() to related-function lists.
man/fpDrawCI.Rd Adds fp_set_favors() to related-function lists.
man/fpColors.Rd Adds fp_set_favors() to related-function lists.
man/forestplot.Rd Updates examples/docs (including spanning example) and notes grob label support.
man/dfHRQoL.Rd Moves/expands dataset documentation to R/data-descriptions.R.
man/HRQoL.Rd Moves/expands dataset documentation to R/data-descriptions.R.
inst/examples/fp_set_favors_example.R Adds runnable example for fp_set_favors().
inst/examples/forestplot_example.R Updates examples and adds spanning demonstration.
data/inventors_vs_mello.rda Adds the new example dataset binary.
README.md Mentions new spanning and grob-in-labeltext capabilities.
R/text_styling.R Implements fp_span() and selector-based styling helpers incl. fp_set_summary().
R/private_prepLabelText.R Adjusts label preparation to avoid is.na() on non-atomic/grob cells.
R/private_prGetLabelsList.R Propagates span attributes and supports grob label cells.
R/private_plot.forestplot_xaxis.R Adds rendering for favors indicators in/around x-axis area.
R/private.R Updates label printing to support spanning across columns.
R/prFpGetGraphTicksAndClips.R Threads graph_favors through axis object for plotting.
R/fp_insert_row.R Refactors row insertion; adds span-aware header handling and collision checks.
R/fp_extract_labeltext.R Adds fp_extract_labeltext() and fp_extract_labels() plus grouped extraction utilities.
R/fp_decorate_graph.R Adds fp_set_favors() helper and related plotting adjustments.
R/forestplot.grouped_df.R Refactors grouped-data handling and stores estimate column names for downstream helpers.
R/forestplot.default.R Standardizes default colgap handling.
R/forestplot.data.frame.R Stores source data + tidy estimate column names for downstream helpers.
R/forestplot.R Updates roxygen docs to mention grob label support.
R/drawForestplotObject.R Refactors plotting setup and adjusts axis layout for outside favors indicators.
R/data-descriptions.R New consolidated dataset documentation (HRQoL/dfHRQoL/inventors_vs_mello).
R/data-HRQoL.R Removes older dataset documentation source file.
NEWS.md Adds 3.2.0 release notes.
NAMESPACE Exports newly added helpers.
DESCRIPTION Bumps version to 3.2.0 and enables LazyData.
CRAN-SUBMISSION Adds CRAN submission metadata file.
.gitignore Ignores Rplots.pdf.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +50
safeLoadPackage("dplyr")
safeLoadPackage("tidyr")

if (!is.data.frame(x)) {
stop("'x' must be a data.frame or grouped_df")
}

dots <- rlang::enquos(...)
if (length(dots) > 0 && !is.null(cols)) {
stop("Provide either tidyselect columns via '...' or explicit 'cols', not both")
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fp_extract_labeltext() uses rlang::enquos(...) but never calls safeLoadPackage("rlang"). Because rlang is listed under Suggests, this function will error if the user doesn't have rlang installed.

Suggestion: add safeLoadPackage("rlang") near the top (alongside the existing dplyr/tidyr checks).

Copilot uses AI. Check for mistakes.
stop("Unkown label columns ", paste(lacking_match, collapse = ", "),
" not present among: ", paste(names(x$labels), collapse = ", "))
stop(
"Unkown label columns ", paste(lacking_match, collapse = ", "),
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in error message: "Unkown" should be "Unknown".

Suggested change
"Unkown label columns ", paste(lacking_match, collapse = ", "),
"Unknown label columns ", paste(lacking_match, collapse = ", "),

Copilot uses AI. Check for mistakes.
Comment on lines 31 to 32
\item{txt}{The text to styl}

Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in docs: "The text to styl" should be "The text to style".

Copilot uses AI. Check for mistakes.
@gforge gforge merged commit 77b2ba2 into master Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants