Skip to content

Include random-effect groups in formatted parameter labels - #1326

Open
M-Colley wants to merge 4 commits into
easystats:mainfrom
M-Colley:oss-sweep/insight-406
Open

M-Colley wants to merge 4 commits into
easystats:mainfrom
M-Colley:oss-sweep/insight-406

Conversation

@M-Colley

@M-Colley M-Colley commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Add group_in_parameter = TRUE to format_table(). It distinguishes random-effect standard deviations and correlations that share a parameter label. The output includes a separate Group column.

Fixes #406.

Validation

The mixed-model example from the issue produced distinct labels for both grouping factors. The installed regression passed all six assertions. The full Windows package check returned Status OK with 2,517 passing assertions. Air and changed-file lint passed.

Offer an opt-in format_table argument to distinguish random-effect terms with identical labels. Keep the grouping column available for downstream table rendering.

Refs easystats#406
@M-Colley

M-Colley commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

This PR fixes #406. With group_in_parameter = TRUE, format_table() includes group names in random-effect standard deviation and correlation labels. The separate Group column is available for downstream formatting.

Comment thread R/format_table.R Outdated
verbose = TRUE,
...
...,
group_in_parameter = FALSE

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please move group_in_parameter before verbose (verbose and ... should always be last arguments)

@strengejacke
strengejacke requested a lite review from Copilot December 4, 2026 13:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open issues
1 file not reviewed
  • man/format_table.Rd: Generated file
What changed in this PR

Adds an opt-in group_in_parameter argument to format_table() so random-effect SD/Cor parameter labels can include their grouping factor, helping disambiguate duplicated labels in mixed models (Fixes #406).

Changes:

  • Add group_in_parameter argument and internal helper to append grouping factor to random-effect Parameter labels when applicable.
  • Add test coverage for grouped parameter labeling behavior and edge cases (missing Group, Residual handling).
  • Document the change in NEWS.md.
File Description
R/​format_table.R Adds group_in_parameter arg and .format_parameter_groups() helper; tweaks df empty-string handling.
tests/​testthat/​test-format_table_groups.R New tests validating grouped parameter labeling and edge cases.
NEWS.md Notes new format_table(group_in_parameter = TRUE) behavior.

Review effort: Lite

Comment thread R/format_table.R Outdated
if (stats %in% names(x) && "df" %in% names(x)) {
if (is.character(x$df)) {
x$df[x$df == ""] <- NA_character_
x$df[!nzchar(x$df, keepNA = TRUE)] <- NA_character_
Comment thread R/format_table.R Outdated
} else if (stats %in% names(x) && "df_error" %in% names(x)) {
if (is.character(x$df_error)) {
x$df_error[x$df_error == ""] <- NA_character_
x$df_error[!nzchar(x$df_error, keepNA = TRUE)] <- NA_character_
Comment thread R/format_table.R
Comment on lines 135 to 155
x,
pretty_names = TRUE,
stars = FALSE,
stars_only = FALSE,
digits = 2,
ci_width = "auto",
ci_brackets = getOption("easystats_ci_brackets", TRUE),
ci_separator = getOption("easystats_ci_separator", ", "),
ci_digits = digits,
p_digits = 3,
rope_digits = digits,
ic_digits = 1,
zap_small = FALSE,
preserve_attributes = FALSE,
exact = TRUE,
use_symbols = getOption("insight_use_symbols", FALSE),
select = NULL,
verbose = TRUE,
...
...,
group_in_parameter = FALSE
) {
Comment thread R/format_table.R Outdated
Comment on lines +97 to +99
#' @param group_in_parameter Logical. If `TRUE`, include the grouping factor in
#' the labels for random-effect standard deviations and correlations. The
#' result includes the separate `Group` column.
@strengejacke strengejacke added the Revisions required 💥 A review has been submitted and changes requested. label Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Revisions required 💥 A review has been submitted and changes requested.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

format_table() should combine Group and Parameter columns like print_*()

3 participants