I am new to R and i am formatting my regression tables for the first time. I would like to add a line above "Working class" in the table below. This line should show "Reference category: Upper-class". Could someone please guide me a bit and maybe suggests some interesting examples/links where i can find formatted tables using the modelsummary function?
Here is my code:
results <-list("Pooled OLS" = Pooled.ols, "Fixed effects" = fixed.effects)
# Coefficients
cm <- c( 'age' = 'Age', 'I(age^2)' = 'Age square', 'wc' = 'Working class','mc' = 'Lower-middle class')
# Output Table
modelsummary(results, stars = TRUE,statistic = 'std.error', type= "html",
fmt= '%.4f',coef_map=cm
)
You can use the
add_rows
argument as follows:Edit: I initially misunderstood the question and thought you wanted to add a horizontal line to separate rows. Since this can often be useful when we want to add custom rows to a table, I leave my (wrong but relevant) answer below.
As of today (2020-12-03),
modelsummary
can produce model objects compatible with four table-drawing packages:kableExtra
(default),gt
,flextable
andhuxtable
. Each of those packages allows you to customize the look of your tables, but they each have different approaches.For example, if you want to customize the default HTML table produced by
kableExtra
, you could feed custom CSS to therow_spec
function:Note that
kableExtra
uses a slightly different approach for LaTeX/PDF output. See the package documentation.If you would rather use the
gt
package, you can set theoutput
argument and then usegt
'stab_style
function: