How to print (to paper) a nicely-formatted data frame

后端 未结 10 2052
深忆病人
深忆病人 2020-12-07 08:41

I\'d like to print nicely-formatted data frames to paper, ideally from within a script. (I am trying to collect data using an instrument and automatically process and print

10条回答
  •  情歌与酒
    2020-12-07 09:13

    The grid.table solution will indeed be the quickest way to create PDF, but this may not be the optimal solution if you have a fairly long table. RStudio + knitr + longtable make it quite easy to create nicely formatted PDFs. What you'll need is something like:

    \documentclass{article}
    \usepackage{longtable}
    \begin{document}
    
    <>=
    library(xtable)
    
    df = data.frame(matrix(rnorm(400), nrow=100))
    xt = xtable(df)
    print(xt, 
          tabular.environment = "longtable",
          floating = FALSE
          )
    @
    \end{document}
    

    Pls see this post for more details.

提交回复
热议问题