So I'm making a table with my regression coefficients using stargazer and I can't figure out how to make the columns wider.
stargazer(fit2, fit3, type="html",
dep.var.labels=c(""),
covariate.labels=c("PVI","Research Level","Minority Serving Institution", "Women's College", "Prestige","Control Level (private = 1)", "Intercept 1", "Intercept 2"), keep.stat = "all",
title = "Table 1. Ordered Logit Estimates of Chicago Statement Endorsement",
ord.intercepts = TRUE,
column.sep.width = "20pt",
out="models.htm")
Here's my code. It doesn't matter what value I put in for column.sep.width, the columns don't move.
stargazer
with type="html"
returns html texts. You can insert html styling, for example, for fixed column widths, eg, <col width="20">...<col width="20">
.
library(stargazer)
linear.1 <- lm(rating ~ complaints + privileges + learning
+ raises + critical, data=attitude)
linear.2 <- lm(rating ~ complaints + privileges + learning, data=attitude)
attitude$high.rating <- (attitude$rating > 70)
probit.model <- glm(high.rating ~ learning + critical + advance, data=attitude,
family = binomial(link = "probit"))
tbl <- stargazer(linear.1, linear.2, probit.model, title="Regression Results",
type="html")
set_html_tbl_widths <- function(stargazer_html_obj,
width_left=30,
width_cols=rep(20, num_cols),
num_cols=3, filename=NULL) {
html_line <- c(paste0('<col width=',as.character(width_left),'>'))
num_cols <- length(width_cols)
for (col in 1:num_cols) {
html_line <- append(html_line,
paste0('<col width=',as.character(width_cols[col]),'>'))
}
new_html <- c(stargazer_html_obj[1:2], html_line,
stargazer_html_obj[3:length(stargazer_html_obj)])
if (!is.null(filename)) {
write(new_html,
file=filename)
}
return(new_html)
}
set_html_tbl_widths(tbl,
filename="models.html")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.