jtools icon indicating copy to clipboard operation
jtools copied to clipboard

Rename terms using partial string matching

Open mattysimonson opened this issue 2 years ago • 0 comments

Renaming (and filtering out) coefficients in plot_summs() and export_summs() is already straightforward, but it could be made less cumbersome through partial string matching. Consider your example from the plot_summs documentation

plot_summs(fit1, fit2, fit3,
           coefs = c("Frost Days" = "Frost", "% Illiterate" = "Illiteracy",
                     "Murder Rate" = "Murder"),
           scale = TRUE, robust = TRUE)

Supposed now the model contained Frost * Murder. I would have to type in "Frost Days x Murder Rate" = "Frost:Murder" for the interaction. Ideally, though, plot_summs would recognize that if I wanted to remane Frost and Murder then I would also want to rename the interaction the same way. This issue also applies to export_summs.

(one complication is that interaction terms often require a linebreak after the x symbol in order to comfortably fit in a plot without blowing up the labeling area)

Aside from interactions, partial string matching would be a useful feature in the event that I simply had a lot of variables I wanted in include with similar names. If my data contained region_north, region_west, region_south, and region_east, it would be great if I could type coef = "region"to catch them all. A complementarydrop_coefs argument` would help as well.

All of this is inspired by the new fixest package's etable function which makes including, excluding, and renaming very easy. See the keep, drop, order and dict arguments: https://lrberge.github.io/fixest/reference/etable.html

mattysimonson avatar Apr 11 '22 05:04 mattysimonson