rstudio - Rstudio Rmarkdown编织到多个pdf?
问题描述
我可以在 Rstudio 中为不同的页面范围(或使用某种分隔符)输出多个 pdf 文件吗?
解决方案
这是我正在使用的一个技巧,以防您找不到简单的方法(在 ubuntu 上,安装pdftk之后):
除了 rmd 文件,我创建了一个 R 脚本,它编辑 rmd 文件生成的 pdf 并将其拆分为更小的 pdf。
例子:
# 1 KNIT THE RMD FILE AND GENERATE A SINGLE PDF WITH ALL THE PAGES
rmarkdown::render('~/my_rmd_file.Rmd')
# 2 CUT THE FIRST 5 PAGES OF THE PDF
# 2.1 make up a name for the smaller pdf:
name_for_the_top5pages_pdf <- "my_rmd_file_top5.pdf"
# 2.2 compose the command that edits the pdf:
cmd_extract_first_5_pages <- paste0("pdftk my_rmd_file cat 1-5 output ",name_for_the_top5pages_pdf)
# 2.3 run the command
system(cmd_extract_first_5_pages)
它将保留原始 pdf 并使用前 5 页创建另一个。
推荐阅读
- jquery - 如何通过动态生成的 AJAX-Table 修复 jQuery 分页
- html - 我不明白标签
- git - Visual Studio 2019 仅将 git 文件推送到远程存储库
- python-3.8 - Python排序列表基于另一个列表中具有匹配模式的值
- pytorch - Pytorch ResNet 模型未按预期使用 GPU 内存大小
- reactjs - 如何在 React Router v2 中为特定参数值渲染嵌套路由?
- python - FastAPI/Pydantic 接受任意发布请求正文?
- azure - 使用 Azure Functions 复制 Azure 搜索的索引
- unit-testing - 使用 vue-test-utils v1 找到非存根转换包装器的最佳方法
- authentication - 询问登录凭据的共享点 Web 部件