Rotating a table in PDF output from RMarkdown with more than one page

半腔热情 提交于 2021-01-28 12:01:18

问题


I want to rotate a wide table in my PDF output. I came across this fantastic question, but my table is longer.

When I copy/paste one of the examples shown in that question, it works nice using RMarkdown.

library(kableExtra)

kable(iris[1:5,],
      format = "latex", booktabs = TRUE) %>%
  kableExtra::landscape()

However, if we remove the subsetting we see that the table exceeds the dimension of the page.

library(kableExtra)

kable(iris,
      format = "latex", booktabs = TRUE) %>%
  kableExtra::landscape()

So my question is very simple: how can we create as many PDF pages as needed by splitting the table in parts?


回答1:


Can you try this (sorry I can't comment) :

dt <- iris 
kable(dt, "latex", longtable = T, caption = "title") %>% 
kable_styling(font_size = 7, latex_options = c("repeat_header"),repeat_header_text = "",
                    full_width = F) %>% kableExtra::landscape()

This seems to work for me. Here's the result : pdf output Is it what you want?



来源:https://stackoverflow.com/questions/55362295/rotating-a-table-in-pdf-output-from-rmarkdown-with-more-than-one-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!