如何使用命令行运行R语言的rmd rmarkdwon文件

博客展示了运行命令的例子,包含文件相关内容,给出了运行命令的操作及最终结果,聚焦于信息技术中命令运行的演示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

运行下面命令:

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
> 
> 

结果:

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值