让 Stargazer Column 标签打印在两行或三行上? [英] Getting Stargazer Column labels to print on two or three lines?

查看:13
本文介绍了让 Stargazer Column 标签打印在两行或三行上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些模型的标题很长,以便完全解释.让他们在两行上打印他们的描述符或标题会很有帮助.这会读取换行符,但生成的乳胶输出无法识别它.

I have some models that have long titles to be fully explanatory. It would be helpful to have them print their descriptors or titles on two lines. This reads the line break character, but the resulting latex output doesn't recognize it.

var1<-rnorm(100)
var2<-rnorm(100)
df<-data.frame(var1, var2)
mod<-lm(var1~var2)
library(stargazer)
stargazer(mod, column.labels='my models
need long titles')

谢谢.

推荐答案

一个选项:您可以为换行符 (\) 和表格列对齐 (&).请注意,每个 都需要在 R 中用另一个 转义".

One option: You can insert latex codes for newline (\) and table column alignment (&). Note that each needs to be "escaped" in R with another .

stargazer(mod, column.labels='my models\\ & need long titles')

另一种方法是多行.对于每列具有不同长度标题的更复杂的表格,这可能会更容易.您需要将 usepackage{multirow} 添加到文档序言中.

Another way is to multirow. This could be easier for more complex tables with different length headings on each column. You will need to add usepackage{multirow} to your document preamble.

stargazer(mod, column.labels='\multirow{2}{4 cm}{my models need long titles}')

您还需要对 stargazer 的乳胶输出进行后期编辑,以在变量标题下方插入一些额外的行(使用 \),以便表格的其余部分也向下移动(如在下面的摘录中):

You will also need to post-edit the latex output from stargazer to insert some extra lines (using \) below the variable headings so that the rest of the table gets moved down also (as in the exceprt below):

& multirow{2}{4 cm}{my models need long titles} \ 
\  % note the extra line inserted here before the horizontal rule
hline \[-1.8ex] 

这篇关于让 Stargazer Column 标签打印在两行或三行上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆