writing data frame to pdf table

后端 未结 4 1951
青春惊慌失措
青春惊慌失措 2020-12-05 12:46

I have a data frame which I would like to write it to a pdf file in organized fashion.

For example, my df looks like this:

Date    County    Trade
1         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-05 13:09

    The grid.table solution will be the quickest way to create a PDF for short tables, but this solution will not work as is if you have a table that's longer than 1 page. RStudio + knitr + longtable is probably the way to go 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.

提交回复
热议问题