【问题标题】:Resizing a stargazer table in Knitr在 Knitr 中调整观星表的大小
【发布时间】:2015-08-05 16:18:00
【问题描述】:

我使用 knitr 整理了一份文档,虽然大部分文档看起来都不错,但有一个回归表太宽,无法在不做任何改动的情况下放在页面上。

回归表是使用 stargazer 生成的,非常宽。

我已尝试按如下方式调整整个块的大小:

{r, echo=FALSE, resize.width=10, results='asis'}

stargazer( table...)

但在生成调整大小的输出方面没有运气。是不是我做错了什么,不能通过块选项调整这些观星表的大小吗?

谢谢!

【问题讨论】:

    标签: r latex knitr stargazer


    【解决方案1】:

    您可以使用 .css 文件来调整输出大小。

    在 YAML 中添加:

    ---
    output: 
    html_document:
        css: custom.css
    ---
    

    您可以在 custom.css 文件中放置:

    table {
      width: 100%;  
    } 
    

    将 custom.css 放在同一个文件夹中通常更容易,并注意您的最终输出仍然是独立的。

    【讨论】:

      【解决方案2】:

      您可以操纵观星器的选项来调整观星器表的大小。对于 R markdown 的 PDF 输出,请尝试以下操作:

      stargazer(model_1, model_2, model_3, model_4, model_5,
                type = 'latex',
       
                header=FALSE, # to get rid of r package output text
      
                single.row = TRUE, # to put coefficients and standard errors on same line
      
                no.space = TRUE, # to remove the spaces after each line of coefficients
      
                column.sep.width = "3pt", # to reduce column width
      
                font.size = "small" # to make font size smaller
      
      )
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-19
        • 1970-01-01
        • 1970-01-01
        • 2016-02-04
        • 1970-01-01
        • 2016-06-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多