r-使用观星器使立柱变宽

  • 本文关键字:用观 r 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输入什么值,列都不会移动。

stargazertype="html"返回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")

相关内容

  • 没有找到相关文章

最新更新