Sha*_*anu 2 r r-markdown docker
如何test.rmd使用 Docker将以下内容转换为输出作为.html文档?
如果不需要在 docker 容器中设置 RStudio,我无法在这里找到一个简短的示例。
测试文件
---
title: "Test"
author: "John Doe"
date: "5/15/2019"
output:
html_document:
theme: lumen
---
## R Markdown
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
## Scatter Plot
```{r}
library(ggplot2)
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()
``
Run Code Online (Sandbox Code Playgroud)
Dir*_*tel 10
这是基于我为 Rmd 制作的并且我在本地拥有的Rocker 容器为您提供的答案(有两个更正/更改)。它相当小:R 加上rmarkdown一个完整的 LaTeX 堆栈(这方面对我来说很重要,对你来说可能不重要)和其他一点,但是ggplot2. 您可以docker pull rocker/r-rmd从Docker Hub的Rocker 帐户使用标准下载它。
我不得不对您的 Rmd 文件进行两次更改。首先,我在最后一行添加了缺少的第三个反引号。然后,我还必须删除流明主题。这可能来自另一个包——我不记得了。之后,以下命令可以解决问题(您的示例是另存为file.Rmd):
docker run --rm -ti -v${PWD}:/work -w/work \
rocker/r-rmd Rscript -e 'rmarkdown::render("file.Rmd")'
Run Code Online (Sandbox Code Playgroud)
edd@rob:~/git/stackoverflow/56157292(master)$ docker run --rm -ti -v${PWD}:/work -w/work rocker/r-rmd Rscript -e 'rmarkdown::render("file.Rmd")'
processing file: file.Rmd
|................................ | 50%
ordinary text without R code
|.................................................................| 100%
label: unnamed-chunk-1
output file: file.knit.md
/usr/bin/pandoc +RTS -K512m -RTS file.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+smart --output file.html --email-obfuscation none --self-contained --standalone --section-divs --template /usr/lib/R/site-library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /tmp/Rtmp6683qu/rmarkdown-str1417442cc.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
Output created: file.html
edd@rob:~/git/stackoverflow/56157292(master)$
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
802 次 |
| 最近记录: |