【问题标题】:Long table description in kable and stargazerkable 和 stargazer 中的长表描述
【发布时间】:2019-02-17 15:38:51
【问题描述】:

这就是我现在在 stargazer 中制作表格的方式:

set.seed(1)
data1 <- data.table(x = seq(200), y = 2*seq(200) + rnorm(200, sd = 10))

model <- lm(y ~ x, data1)
summary(model)

stargazer(model, 
      title = "Regression results", align = TRUE, header = FALSE,
      no.space = FALSE,
      font.size = "small",
      df = FALSE)

如何修改代码以在表格开始前添加长表格描述?我实际上对 kable 有同样的问题 - 我可以通过

指定标题
my_table %>% kable("latex", booktabs = T, caption = "Summary statistics")

如何插入位于其上方的表格的详细描述?

【问题讨论】:

    标签: r stargazer kable kableextra


    【解决方案1】:

    您可以在表格开始之前添加您想要的 Latex 代码:

    set.seed(1)
    data1 <- data.table(x = seq(200))
    data1[, y:= 2*x + rnorm(200, sd = 10)]
    
    model <- lm(y ~ x, data1)
    summary(model)
    
    star <-stargazer(model, 
              title = "Regression results", align = TRUE, header = FALSE,
              no.space = FALSE,
              font.size = "small",
              df = FALSE)
    
    star_2 <- c(star[1:2], "How do I modify the code to add a long table description before the table starts? Just modify the latex output", star[3:length(star)]) 
    

    我修改了您的示例,因为我在创建 data.table 时出错

    最好的!

    【讨论】:

    • 谢谢!文本没有准确地放在我需要的地方,但我明白了你的意思。所以我无法通过 stargazer 或 kable 来做到这一点,唯一的选择是修改输出的乳胶代码。
    猜你喜欢
    • 2022-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多