[英]Stargazer: put several lines under a table
Below is a code to put a stargazer
table in R markdown.下面是在 R markdown 中放置观
stargazer
表的代码。 To do so, I used some code found in the documentation of the stargazer
package and I customize it a little bit.为此,我使用了
stargazer
package 文档中的一些代码,并对其进行了一些定制。
---
title: "test stargazer in r markdown"
author: ""
date: "18/09/2019"
header-includes:
- \usepackage{dcolumn}
output: pdf_document
---
```{r results='asis', echo = FALSE, message = FALSE}
library(stargazer)
set.seed(5)
temp <- rnorm(500, mean = 80, sd = 12)
sales <- 2 + temp * 3
for (i in 1:length(sales)) {
if (temp[i]<75 | temp[i]>95) sales[i] <- sales[i] + rnorm(1, 0, 25)
else sales[i] <- sales[i] + rnorm(1, 0, 8)
}
female <- rnorm(500, mean = 0.5, sd = 0.01)
icecream <- as.data.frame(cbind(temp, sales, female))
reg.model <- lm(sales ~ temp + female, data = icecream)
library(sandwich)
cov <- vcovHC(reg.model, type = "HC")
robust.se <- sqrt(diag(cov))
stargazer(reg.model, reg.model,
se = list(NULL, robust.se),
column.labels = c("default", "robust"),
align = TRUE,
notes.align = "l",
type = "latex",
header = FALSE,
notes = "Tout ceci est un texte bidon qui a pour unique but de prendre de la place afin de voir comment les notes sont traitées par le package 'stargazer'."
)
```
The text in the notes
argument is long and therefore increases the width of the table whereas I'd like the text to be confined (with multiple break lines if necessary) under the original (narrower) table. notes
参数中的文本很长,因此会增加表格的宽度,而我希望将文本限制在原始(较窄)表格下(如有必要,使用多个换行符)。 I don't think this is possible with the functions of the package (but I may be wrong), is there a tweak to make that possible?我认为 package 的功能不可能做到这一点(但我可能错了),是否有任何调整可以做到这一点?
First image is the obtained output, second image is the desired output:第一张图是得到的output,第二张图是想要的output:
Edit: I would like a solution so that the lines are broken automatically, not manually编辑:我想要一个解决方案,使线条自动断开,而不是手动断开
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.