我正在docker容器中运行Shiny应用程序。该应用程序从Google Analytics(分析)中提取/处理数据,然后将这些数据传递到.Rmd
文件中,然后将该文件编织到投影仪演示文稿中,然后提供该文件供下载。 docker映像正在R v3.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()
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)
Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.19.so
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=C
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.4.4
发光的服务器日志:
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
会话的容器中,我可以在render()
文件上运行...knit.md
并创建最终的投影仪演示文稿.pdf
,而不会出现问题。只是将*.knit.md
转换为.pdf
并提供下载的最后一步失败了。
当我查看包含我的dir
文件的.Rmd
时,没有.tex
文件,只有GA_report.knit.md
和GA_report.utf8.md
。
我的.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)
可以在容器中访问我的自定义投影仪主题
root@de4bd1ee457a:/# kpsewhich beamerthemeSwCustom.sty
/opt/TinyTeX/texmf-dist/tex/latex/beamer/beamerthemeSwCustom.sty
这可能是怎么回事?在完成文件过程中,似乎所有迹象都应指向是,但是我对可能的问题感到困惑。
答案 0 :(得分:1)
我相信这与Shiny Server中的最大超时错误有关。我的docker容器正在运行Shiny Server,this issue on the Shiny Server github建议在Shiny Server的downloadHandler()
中存在硬编码的超时。由于我的.Rmd
文件很大,因此转换为.pdf
所需的时间比自动超时要长得多。由于downloadHandler()
从未提供我期望下载的内容,因此我将取消该过程,并且最终也不会创建最终的.pdf
。
将我的应用程序重构为包括两个按钮,一个用于生成报告,一个用于下载报告。通过允许在downloadedHandler()
之外进行.Rmd
的编织,从而避免了downloadHandler()
的硬编码超时。