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

查看:63
本文介绍了是否可以在两行或三行上打印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\nneed 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天全站免登陆