render()无法在容器化应用程序中将.Rmd转换为.pdf
我正在docker容器中运行一个闪亮的应用程序。该应用程序从Google Analytics中提取/处理数据,将这些数据传递到render()无法在容器化应用程序中将.Rmd转换为.pdf,r,docker,r-markdown,R,Docker,R Markdown,我正在docker容器中运行一个闪亮的应用程序。该应用程序从Google Analytics中提取/处理数据,将这些数据传递到.Rmd文件中,将该文件编织成beamer演示文稿,然后提供该文件供下载。docker映像正在运行Rv3.4.4.和rmarkdown v1.10。除了最后一步,我使用render()将.Rmd编织成一个.pdf,应用程序正常工作 pdflatex已安装并可在我的容器中访问: root@de4bd1ee457a:/# pdflatex This is pdfTeX, Ve
.Rmd
文件中,将该文件编织成beamer演示文稿,然后提供该文件供下载。docker映像正在运行Rv3.4.4.
和rmarkdown v1.10
。除了最后一步,我使用render()
将.Rmd
编织成一个.pdf
,应用程序正常工作
pdflatex
已安装并可在我的容器中访问:
root@de4bd1ee457a:/# pdflatex
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017) (preloaded format=pdflatex)
restricted \write18 enabled.
我的sessionInfo()
服务器日志:
Listening on http://127.0.0.1:45211
2018-08-07 13:49:19> No scopes have been set, set them via
options(googleAuthR.scopes.selected) -
no authentication attempted.
Attaching package: ‘dplyr’
The following objects are masked from ‘package:stats’:
filter, lag
The following objects are masked from ‘package:base’:
intersect, setdiff, setequal, union
2018-08-07 13:49:20> Default Google Project for googleAnalyticsR is now set.
This is shared with all googleAnalyticsR users.
If making a lot of API calls, please:
1) create your own Google Project at https://console.developers.google.com
2) Activate the Google Analytics Reporting API
3) set options(googleAuthR.client_id) and options(googleAuthR.client_secret)
4) Reload the package.
2018-08-07 13:49:20> Set API cache
2018-08-07 13:49:20> No environment argument found, looked in GA_AUTH_FILE
Attaching package: ‘jsonlite’
The following object is masked from ‘package:shiny’:
validate
2018-08-07 13:49:36> Downloaded [5045] rows from a total of [5045].
processing file: GA_report.Rmd
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
`geom_smooth()` using method = 'loess' and formula 'y ~ x'
output file: GA_report.knit.md
我已验证是否成功创建了GA_report.knit.md
(以及.Rmd
文件中的所有图形)。在R
会话的容器中,我可以在..knit.md
文件上运行render()
,并创建最终的beamer演示文稿.pdf
。只是,*.knit.md
转换为.pdf
并提供下载的最后一步失败了
当我查看包含.Rmd
文件的目录时,没有.tex
文件,只有GA_report.knit.md
和GA_report.utf8.md
my.Rmd
---
output:
beamer_presentation:
theme: "SwCustom"
title: "`r paste0('Draft report: ', params$client)`"
date: "`r Sys.Date()`"
toc: FALSE
classoption: aspectratio=169
editor_options:
chunk_output_type: console
params:
data: NA
client: NA
---
render()
语句
render("report/GA_report.Rmd",
output_format = "all",
output_file = file,
params = params,
envir = new.env(parent = globalenv()),
clean = FALSE,
quiet = FALSE)
我的自定义beamer主题可以在容器中访问
root@de4bd1ee457a:/# kpsewhich beamerthemeSwCustom.sty
/opt/TinyTeX/texmf-dist/tex/latex/beamer/beamerthemeSwCustom.sty
这到底是怎么回事?在完成文件时,似乎所有的迹象都应该指向“是”,但我不知道问题出在哪里 我认为这与服务器中的最大超时错误有关。我的docker容器正在运行Shinny Server,这表明Shinny Server中的downloadHandler()
中存在硬编码超时。由于我的.Rmd
文件相当大,因此转换为.pdf
比自动超时需要更长的时间。由于downloadHandler()
从未提供我期望的下载内容,因此我将取消该过程,并且最终的.pdf
从未创建
我的解决方案是重构我的应用程序,使其包含两个按钮,一个用于生成报告,另一个用于下载报告。通过允许在downloadHandler()
之外编织.Rmd
,这绕过了downloadedHandler()的硬编码超时 pandoc是否安装在容器中。据我所知,knit to pdf需要它,但不确定它是否能解决安装了pandoc的问题。至少,当我查看pandoc--version
时,我得到了pandoc1.19.2.1
。
root@de4bd1ee457a:/# kpsewhich beamerthemeSwCustom.sty
/opt/TinyTeX/texmf-dist/tex/latex/beamer/beamerthemeSwCustom.sty