Extend annotate_lineplot_df(): mean_se, custom labels, blank timepoints - #317
Open
Melkiades wants to merge 3 commits into
Open
Extend annotate_lineplot_df(): mean_se, custom labels, blank timepoints#317Melkiades wants to merge 3 commits into
Melkiades wants to merge 3 commits into
Conversation
Report the mean +/- 1 standard error interval in the annotation table, matching the error bars drawn by gg_lineplot(variability = "se") so the table and plot always agree. The row label defaults to "Mean -/+ 1xSE" and is configurable via the new se_label argument.
Contributor
Unit Tests Summary 1 files 314 suites 1m 53s ⏱️ Results for commit 0fb818a. ♻️ This comment has been updated with latest results. |
Contributor
Unit Test Performance DifferenceAdditional test case details
Results for commit 84c8aa9 ♻️ This comment has been updated with latest results. |
Contributor
Code Coverage SummaryDiff against mainResults for commit: 0fb818a Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Add a labels argument to override statistic row labels (e.g. labels = c(mean = "LS mean") for an MMRM plot) and a blank_timepoints argument to blank the continuous statistics at fixed timepoints while keeping n, for a constant change-from-baseline visit where the mean/SD/CI are 0 by construction.
The general labels argument already relabels any statistic, so the special-case se_label was redundant. The mean_se row keeps its default "Mean -/+ 1xSE" label and is now relabelled the same way as every other statistic, e.g. labels = c(mean_se = "Mean +/- SE").
Melkiades
commented
Sep 3, 2026
Comment on lines
+240
to
+257
| # Blank the continuous statistics at fixed timepoints (e.g. a constant-zero | ||
| # change-from-baseline visit in an MMRM plot), where a "0.00" mean/SD/CI is an | ||
| # artifact of the constant rather than a real estimate. The count ("n") is a | ||
| # genuine value and is kept. | ||
| if (!is.null(blank_timepoints)) { | ||
| missing_tp <- setdiff(blank_timepoints, names(formatted_df)) | ||
| if (length(missing_tp) > 0) { | ||
| cli::cli_warn(c( | ||
| "!" = "Timepoint{?s} in {.arg blank_timepoints} not found: {.val {missing_tp}}.", | ||
| "i" = "Available timepoint columns are {.val {setdiff(names(formatted_df), c(names(formatted_df)[1], 'Group'))}}." | ||
| )) | ||
| } | ||
| n_label <- trimws(stat_labels[["n"]]) | ||
| blank_rows <- is_stat & trimws(raw_labels) != n_label | ||
| for (tp in intersect(blank_timepoints, names(formatted_df))) { | ||
| formatted_df[blank_rows, tp] <- "" | ||
| } | ||
| } |
Contributor
Author
There was a problem hiding this comment.
should we give the option to add 0 instead? or whatever NA label?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
annotate_lineplot_df()gains a"mean_se"summary_statsoption reporting the mean +/- 1 standard error interval, matching the error bars drawn bygg_lineplot(variability = "se"). Its row label defaults to"Mean -/+ 1xSE"and is configurable via the newse_labelargument. (Add SE to annotate_lineplot_df() summary table #307)annotate_lineplot_df()gains alabelsargument to rename statistic rows (e.g.labels = c(mean = "LS mean")for an MMRM plot) and ablank_timepointsargument to blank the continuous statistics at fixed timepoints while keepingn(e.g. a constant change-from-baseline visit where the mean/SD/CI are0by construction). (Add SE to annotate_lineplot_df() summary table #307)These are follow-ups from annotating MMRM change-from-baseline plots:
"mean_se"mirrors the plot's SE error bars in the table (bounds delegate to the same.calc_stats()helper the plot uses, so they can never disagree).labelslets an MMRM plot report "LS mean" instead of the generic "Mean".blank_timepointsremoves the meaningless0.00mean/SD/CI at the constant baseline visit while keeping the sample size.Reference GitHub issue associated with pull request. e.g., 'closes #'
Part of #307.
Pre-review Checklist (if item does not apply, mark is as complete)
usethis::pr_merge_main()devtools::test_coverage()Reviewer Checklist (if item does not apply, mark is as complete)
pkgdown::build_site(). Check the R console for errors, and review the rendered website.devtools::test_coverage()When the branch is ready to be merged:
NEWS.mdwith the changes from this pull request under the heading "# cards (development version)". If there is an issue associated with the pull request, reference it in parentheses at the end update (seeNEWS.mdfor examples).