这不是一个可重复例子…
问题
最近的一个项目里我想在学校机群里编译Rmd生成结果报告,碰到的问题是没有可视化模块的话Rmd编译失败。
而且还有无root权限的限制。
参考了这个issue
跟SO
之后,多种办法试过还是无法编译。用以下代码编译还出错
R -e "rmarkdown::render('script.Rmd',output_file='output.html')"
装xvfb没root的话看起来好麻烦,还没试过
尝试
直接运行
---
title: "Untitled"
author: "TC"
date: "12/20/2019"
output:
html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
#options(bitmapType='cairo')
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
编译后出错:
> rmarkdown::render('test.Rmd',output_file='output.html')
processing file: test.Rmd
|.............. | 20%
ordinary text without R code
|............................ | 40%
label: setup (with options)
List of 1
$ include: logi FALSE
Quitting from lines 10-12 (test.Rmd)
Error in dev.control(displaylist = if (record) "enable" else "inhibit") :
dev.control() called without an open graphics device
Calls: <Anonymous> ... call_block -> block_exec -> chunk_device -> dev.control
In addition: Warning messages:
1: In grDevices::png(f) : no png support in this version of R
2: In (function (filename = if (onefile) "Rplots.svg" else "Rplot%03d.svg", :
unable to load shared object '/sw/R/3.5.2/lib64/R/library/grDevices/libs//cairo.so':
/sw/R/3.5.2/lib64/R/library/grDevices/libs//cairo.so: cannot open shared object file: No such file or directory
3: In (function (filename = if (onefile) "Rplots.svg" else "Rplot%03d.svg", :
failed to load cairo DLL
Execution halted
Capabilities显示各种png 啊jpg啊cairo啊都不支持
> capabilities()
jpeg png tiff tcltk X11 aqua
FALSE FALSE FALSE FALSE FALSE FALSE
http/ftp sockets libxml fifo cledit iconv
TRUE TRUE TRUE TRUE TRUE TRUE
NLS profmem cairo ICU long.double libcurl
TRUE TRUE FALSE TRUE TRUE TRUE
Cairo包
目前尝试到装了Cairo后可以出图
> Cairo.capabilities()
png jpeg tiff pdf svg ps x11 win raster
TRUE TRUE TRUE TRUE TRUE TRUE TRUE FALSE TRUE
感觉很近了,不过试图设置dev依然失败,代码
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, dev="Cairo::CairoPNG")
```
报错:
Quitting from lines 10-11 (test2.Rmd)
Error in dev.control(displaylist = if (record) "enable" else "inhibit") :
dev.control() called without an open graphics device
Calls: <Anonymous> ... call_block -> block_exec -> chunk_device -> dev.control
所以说
求解救怎么才能在这种服务器上优雅的编译Rmd啊…
我现在的替代方案可是手写bash+一堆echo语句来生成html啊…