Skip to content

Backport #309 to maint/v3 (3.5.4) - #312

Merged
ehrlinger merged 3 commits into
maint/v3from
backport/partial-rfsrc-309-maint-v3
Oct 1, 2026
Merged

ehrlinger merged 3 commits into
maint/v3from
backport/partial-rfsrc-309-maint-v3

Conversation

@ehrlinger

@ehrlinger ehrlinger commented Oct 1, 2026 •

Copy link
Copy Markdown
Owner

Backports #309 to maint/v3, ahead of the 3.x release. 3.5.4 is unreleased (CRAN has 3.5.3), so the NEWS bullets go under 3.5.4 and the version stays put.

What it fixes in gg_partial_rfsrc() / plot.gg_partial_rfsrc():

  • partial.type = "mort" stopped with "replacement has 3 rows, data has 23" under the default partial.time. Mortality is summed over every event time, so its data now carry no time column, and both panels are labelled "Predicted Mortality".

  • On a survival forest with xvar2.name, the continuous panel now gives each level its own panel, one line per time horizon, instead of one zigzag per time.

  • A factor xvar2.name is passed to partial.rfsrc() as integer codes, and grp comes back as a factor holding the labels.

  • Factor levels are now coded by the fitted forest, not by newx (2fcf7d0a, raised by Copilot on fix: mortality, grouped survival lines and factor xvar2 in gg_partial_rfsrc #309). A factor re-levelled in newx had passed one level's code under the other's label, for xvar.names and xvar2.name alike. A level the forest was not trained on is now an error.

Adapted for maint/v3

This is a cherry-pick of 9ca657b2 and 2fcf7d0a (-x). The second applied clean; the first needed these conflicts resolved:

Verification (on this branch)

  • devtools::document(), then lintr::lint_package(): 0 lints
  • NOT_CRAN=true VDIFFR_RUN_TESTS=true devtools::test(): FAIL 0, SKIP 5, PASS 1615. The new gg-partial-rfsrc-continuous-survival-by-group baseline from main matches v3's rendering unchanged; 52 baselines before and after.
  • R CMD check --as-cran with the manual, from a git archive export: 1 NOTE (CRAN incoming feasibility). Timed steps total 213 s locally. Tarball 2.4 MB, with no hidden files other than .Rinstignore.

🤖 Generated with Claude Code

Mortality, grouped survival lines and factor xvar2 in gg_partial_rfsrc:
- partial.type = "mort" no longer errors under the default partial.time;
  the time column is left off for mortality.
- plot.gg_partial_rfsrc() continuous panel facets on grp when a survival
  forest has xvar2.name; the y label follows partial.type in every branch.
- A factor xvar2.name is passed to partial.rfsrc() as integer codes and
  grp is labelled with the levels.

Adapted for maint/v3: no labels= argument here, so the shared facet helper
takes no strip labeller; the xvar2.name doc keeps v3's wording plus the
factor sentence. NEWS goes under the unreleased 3.5.4.

(cherry picked from commit 9ca657b)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.40%. Comparing base (0cbe923) to head (1a4440d).
⚠️ Report is 1 commits behind head on maint/v3.

Files with missing lines Patch % Lines
R/gg_partial_rfsrc.R 95.65% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           maint/v3     #312      +/-   ##
============================================
+ Coverage     89.12%   89.40%   +0.27%     
============================================
  Files            50       50              
  Lines          4682     4699      +17     
============================================
+ Hits           4173     4201      +28     
+ Misses          509      498      -11     
Files with missing lines Coverage Δ
R/plot.gg_partial.R 95.23% <100.00%> (+10.43%) ⬆️
R/gg_partial_rfsrc.R 90.19% <95.65%> (-0.32%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ehrlinger and others added 2 commits October 1, 2026 08:46
partial.rfsrc() imposes a level by its integer code in the model, and
make_eval_grid() and partial_with_group() took those codes from newx's
own levels. newx is checked only by column name, so a factor
re-levelled there passed one level's code under the other's label, for
xvar.names and xvar2.name alike. Map through the model's levels and
stop on a level the forest was not trained on.

Raised in review on #309.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2fcf7d0)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ehrlinger

Copy link
Copy Markdown
Owner Author

Added 2fcf7d0a from #309, the fix Copilot's review there prompted: factor levels are now coded by the fitted forest, not by newx. Without it this backport would have shipped the xvar2.name factor path with the same level-swap bug. It applied clean, and its NEWS bullet is copied from main into 3.5.4.

Re-run on 1a4440d3: 0 lints; NOT_CRAN=true VDIFFR_RUN_TESTS=true devtools::test() FAIL 0, SKIP 5, PASS 1615; R CMD check --as-cran with the manual, from a git archive export: 1 NOTE (incoming feasibility). 52 baselines before and after.

@ehrlinger
ehrlinger merged commit deb8fd8 into maint/v3 Oct 1, 2026
10 checks passed
@ehrlinger
ehrlinger deleted the backport/partial-rfsrc-309-maint-v3 branch October 1, 2026 13:14
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.

1 participant