[英]Making columns wider using stargazer?
所以我正在使用 stargazer 制作一個包含回歸系數的表格,但我不知道如何使列更寬。
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")
這是我的代碼。 無論我為 column.sep.width 設置什么值,列都不會移動。
type="html"
的stargazer
返回 html 條文本。 您可以插入 html 樣式,例如,固定列寬,例如<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")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.