I am estimating two binomial logit models and I want to present the results in a stylized table . The code of the models are the following:
library(readxl)
datos_modelo <- read_excel("datos_def_excel")
library(glm2)
modelo_logit_viv <- glm2( SAP ~sexo + edad + IMC + niv_est,
data = datos_modelo, family = binomial(link = "logit"),na.action = "na.omit")
modelo_logit <- glm2(SAP ~ sexo + edad + IMC + niv_est,
data = modelo_logit_viv$model, family = binomial(link = "logit"),na.action = "na.omit")
(I transform the variables that interest me to type factor and create the list etiqs_model
to change the name of the labels that appear in the table that I generate below)
library(sjPlot)
tab_model(modelo_logit,modelo_logit_viv,transform = "exp", title = "Salud autopercibida",pred.labels = etiqs_model, wrap.labels = 10,
string.pred = "Variables",dv.labels = c("Modelo I","Modelo II"),show.se = TRUE,show.r2 = TRUE,
string.est = "ODD-R", p.style = "numeric", string.se = "Er. estánd.",show.ci = FALSE)
In this example both models have the same variables, but in my work the variables differ and that is why I generate a table with two models . This generates the following table:
My questions are:
How can I increase the spacing between columns so that the text in the first column doesn't appear so close together? If you look closely, the text "ODD-R" appears too close to "Standard Er."
How can I add a vertical line or a larger separation between the results of Model I and Model II?
From what I've searched, I think I have to add the argument list=CSS(...)
in tab_model
but I don't know the parameters that I should include in list=CSS(...)
. The biggest help I've found on this is this .
Indeed, the way to adjust the appearance of the tables is by using
css
. A basic example:Result:
What you are looking for:
padding
to a particular column. In this example we will do it on the firstEstimates
of the first model, it is the second columnborder
to the fourth column.The first thing is to use
cat(tab$page.style)
to understand what styles we can configure for our table, in this example, we will use:.col2
and.col4
, and the idea is to do something like this:Result:
Additional documentation that may be useful to you: