• R语言
  • 【求助】stargazer產生的表在knit會換行導致頁面過長

大家好

使用stargazer做比較模型表格時,在程式內看表格很正常,可以清楚看出4個模型的比較

但knit成pdf後的表格(如下圖),4個模型的間距蠻大的所以有換行,導致閱讀不便

不知道有沒有辦法調整?

以下是code和資料

title: "Statistical Methods in Finance"
geometry: margin=1.18in
documentclass: ctexart
output: 
  bookdown::pdf_book: 
    number_sections: yes
    pandoc_args: --listings
    toc: yes
    fig_crop: no
    base_format: rmarkdown::pdf_document
    latex_engine: xelatex
    citation_package: natbib
    dev: "cairo_pdf"
    template: null
    extra_dependencies:
      sourcecodepro:
       - scale=0.85
      sourceserifpro:
       - rmdefault
      sourcesanspro:
       - sfdefault
      awesomebox:
    quote_footer: ["\\hspace*{\\fill} ", ""]
    geometry:
      - top=30mm
      - left=20mm
    includes:
      in_header: header.tex
biblio-style: plainnat #apalike
natbiboptions: "authoryear,round"
link-citations: yes
colorlinks: yes
classoption: "UTF8,a4paper,fontset=adobe,zihao=false"
{r global_options, include = FALSE}
knitr::opts_chunk$set(
  fig.width = 7,
  fig.height = 6,
  echo = TRUE,
  warning = FALSE,
  message = FALSE
)
tidy = TRUE
tidy.opts = list(keep.blank.line = FALSE, width.cutoff = 100)
options(width = 60)
cex.val = 1 # 加在plot裡面的文字大小
warnings('off')
require(dplyr)
require(tidyverse)
require(magrittr)
require(readr)
require(plm)
require(ggplot2)
require(stargazer)

data <- read.csv("C:\\Users\\Yoga\\Desktop\\dairy.csv"
                 , header = T)[, c('FARM', 'YEAR', 'MILK', 'COWS', 'LAND' ,'LABOR', 'FEED')]

pdata=pdata.frame(data,index = c('FARM','YEAR'))
pool=log(MILK) ~ COWS + LAND + LABOR + FEED
poolmodel<-plm(pool, data=pdata, model='pooling')
indmodel<-plm(pool, model='within', effect='individual',data = pdata)
timemodel<-plm(pool, model='within', effect='time',data = pdata)
bothmodel<-plm(pool, model='within', effect='twoways',data = pdata)
stargazer(poolmodel,indmodel,timemodel,bothmodel,type='text',
          column.labels = c("Pooled OLS","FE-individual","FE-time","FE-two-ways"))
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

Matrix products: default

locale:
[1] LC_COLLATE=Chinese (Traditional)_Taiwan.950  LC_CTYPE=Chinese (Traditional)_Taiwan.950   
[3] LC_MONETARY=Chinese (Traditional)_Taiwan.950 LC_NUMERIC=C                                
[5] LC_TIME=Chinese (Traditional)_Taiwan.950    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] stargazer_5.2.2 plm_2.2-5       magrittr_2.0.1  forcats_0.5.0   stringr_1.4.0   purrr_0.3.4    
 [7] readr_1.4.0     tidyr_1.1.2     tibble_3.0.4    ggplot2_3.3.2   tidyverse_1.3.0 dplyr_1.0.2    

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5        bdsmatrix_1.3-4   lubridate_1.7.9.2 lattice_0.20-41   ps_1.5.0          zoo_1.8-8        
 [7] assertthat_0.2.1  digest_0.6.27     lmtest_0.9-38     R6_2.5.0          cellranger_1.1.0  backports_1.2.0  
[13] reprex_0.3.0      evaluate_0.14     httr_1.4.2        pillar_1.4.7      Rdpack_2.1        miscTools_0.6-26 
[19] rlang_0.4.9       readxl_1.3.1      rstudioapi_0.13   callr_3.5.1       whisker_0.4       Matrix_1.2-18    
[25] rmarkdown_2.5     labeling_0.4.2    splines_4.0.3     munsell_0.5.0     broom_0.7.2       compiler_4.0.3   
[31] modelr_0.1.8      xfun_0.19         pkgconfig_2.0.3   clipr_0.7.1       mgcv_1.8-33       maxLik_1.4-6     
[37] htmltools_0.5.0   tidyselect_1.1.0  fansi_0.4.1       crayon_1.3.4      dbplyr_2.0.0      withr_2.3.0      
[43] MASS_7.3-53       rbibutils_2.0     grid_4.0.3        nlme_3.1-149      jsonlite_1.7.1    gtable_0.3.0     
[49] lifecycle_0.2.0   DBI_1.1.0         scales_1.1.1      cli_2.2.0         stringi_1.5.3     farver_2.0.3     
[55] fs_1.5.0          xml2_1.3.2        ellipsis_0.3.1    generics_0.1.0    vctrs_0.3.5       sandwich_3.0-0   
[61] Formula_1.2-4     tools_4.0.3       glue_1.4.2        hms_0.5.3         processx_3.4.5    yaml_2.2.1       
[67] colorspace_2.0-0  gbRd_0.4-11       rvest_0.3.6       knitr_1.30        haven_2.3.1 

使用reprex()時出現error,所以改提供資料連結,還請大家見諒

資料链接:https://pan.baidu.com/s/1ccF2xEVgRRKojIHbdKwNLA
提取码:r6f6

自己頂一下...有沒有高手可以提點這篇沒人回的原因

是發問格式不對?還是問題太簡單?

感激不盡

    rockon8765

    放宽心,没人回跟你帖子或格式没关系,只是估计大家没这方面经验而已。多等等呗。

    没人回太正常了,写在新手须知里第一条

    任何会员都 没有绝对的责任和义务 帮助其他会员解决问题或提供帮助,无人回答的帖子为合理情况,请理解。