Skip to content

modelsummary's coef_rename doesn't work with avg_comparisons #1238

Description

@raffaelemancuso

Consider the following example:

tmp <- mtcars
tmp %<>% mutate(across(cyl, as.factor))
tmp <- set_variable_labels(
  tmp,
  mpg = "Miles per gallon",
  cyl = "Number of cylinders",
  disp = "Displacement"
)
attr(tmp$am, "label")
mod <- lm(mpg ~ cyl + disp, tmp)
modelsummary(dvnames(mod), coef_rename=TRUE)

mod_ame <- avg_comparisons(mod, variables = list(cyl = "reference"))
modelsummary(dvnames(mod_ame), shape=term+contrast~model, coef_rename=TRUE)

which prints:

Image

The labels are lost for both the dependent and the independent variable.

Reported here as per vincentarelbundock/modelsummary#966 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions