Resizing a stargazer table in Knitr

前端 未结 2 1374
清酒与你
清酒与你 2021-01-07 06:06

I\'ve put together a document using knitr and while most of the document looks fine, there\'s one regression table that\'s too wide to fit on a page without some alteration.

相关标签:
2条回答
  • 2021-01-07 06:32

    You can use a .css file to resize the output.

    in the YAML add :

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

    and in a custom.css file you can put :

    table {
      width: 100%;  
    } 
    

    it's often easier to place the custom.css in the same folder, and note that your final output will still be self-contained.

    0 讨论(0)
  • 2021-01-07 06:46

    You can manipulate the options of stargazer to resize your stargazer table. Try the following for PDF output of R markdown:

    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
    
    )
    
    0 讨论(0)
提交回复
热议问题