I have the following, hopefully very easy to solve, problem. I came across the modelsummary package and find it really useful. But I am struggeling to rename the coefficients to symbols, like for example $$\alpha$$.
I tried every possible combination of $ and \ or \ but nothing seems to work. I also tried expression(), which works for me in the ggplot package. (expression(Z[paste(i,", ",2019)], for example)
This is the summary I want to create:
basic_reg <- modelsummary(
list(reg_basis, reg_basis_ausr),
stars = TRUE,
coef_rename = c("$\alpha$", "a", "b", "c"),
gof_omit = 'DF|Deviance|AIC|BIC|Log.Lik.|F|RMSE',
title = 'Table 1: Basic Regressions',
notes = list("Std. Errors in parentheses", "In (2) UK, Singapore, USA, China, France, Hong Kong and Luxembourg are removed and robust Std. Errors are added"),
output = "gt")
gtsave(basic_reg, filename = "basic_reg.png")
I hope someone can help, because the tables look very nice.
A simple approach would be to use the unicode, e.g.
\u03B1
for alpha.Using a minimal reprex based on the default example from
modelsummary
:EDIT A second approach would be to use
gt::html
. When you output togt
the result is agt
table object which can be manipulated using functions fromgt
, e.g. we can usegt::text_replace
to replace text and we can usegt::html
to add some HTML, which besides adding greek letters allows to add super- and subscripts via a<sup>
or<sub>
tag.In the example code I replace a placeholder text
alpha
by the HTML entity for the alpha symbol, and a single letter"c"
by"Delta X_2019"
: