凯布尔和观星台的长桌描述

时间:2019-02-17 15:38:52

标签: r stargazer kable kableextra

这就是我现在在观星台中制作桌子的方式:

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")

如何插入上方的表格的详细说明?

1 个答案:

答案 0 :(得分:0)

您可以在表格开始之前添加所需的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

时出错

最好!