运行下面命令:
R -e "rmarkdown::render('script.Rmd',output_file='output.html')"
例子
文件: script.Rmd
### 我是谁?
> dengfei
### 来干嘛
> 演示如何通过命令行调用rmarkdwon脚本,并生产html
### 来个例子
```{r}
example(plot)
```
运行:
R -e "rmarkdown::render('script.Rmd',output_file='output.html')"
R version 3.5.1 (2018-07-02) -- "Feather Spray"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Microsoft R Open 3.5.1
The enhanced R distribution from Microsoft
Microsoft packages Copyright (C) 2018 Microsoft Corporation
Using the Intel MKL for parallel mathematical computing (using 16 cores).
Default CRAN mirror snapshot taken on 2018-08-01.
See: https://mran.microsoft.com/.
> rmarkdown::render('script.Rmd',output_file='output.html')
processing file: script.Rmd
|................................ | 50%
ordinary text without R code
|.................................................................| 100%
label: unnamed-chunk-1
output file: script.knit.md
/home/dengfei/anaconda3/bin/pandoc +RTS -K512m -RTS script.utf8.md --to html4 --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output output.html --smart --email-obfuscation none --self-contained --standalone --section-divs --template /home/dengfei/anaconda3/lib/R/library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /tmp/RtmpAsliI2/rmarkdown-str133f20c33537.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'
Output created: output.html
>
>