.rmd文件的访问名称,并在R中使用 [英] Access name of .rmd file and use in R
本文介绍了.rmd文件的访问名称,并在R中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编织一个名为MyFile.rmd
的降价文件.
在编织过程中如何访问字符串MyFile
并将其用于:
I am knitting a markdown file called MyFile.rmd
.
How can I access the string MyFile
during the knitting and use it for:
- 在YAML标头的标题部分中使用吗?
-
在随后的R块中使用?
- use in the title section of the YAML header?
use in subsequent R chunk?
---
title: "`r rmarkdown::metadata$title`"
author: "My Name"
date: "10. Mai 2015"
output: beamer_presentation
---
## Slide 1
```{r}
rmarkdown::metadata$title
```
导致...
...这是错误的,因为我要编织的文件的名称不同.
... which is incorrect as the file I am knitting is named differently.
> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] digest_0.6.8 htmltools_0.2.6 rmarkdown_0.5.1 tools_3.1.2 yaml_2.1.13
推荐答案
只需总结一下益辉的答案:
Just summarize Yihui's answer:
---
title: "`r knitr::current_input()`"
author: "My Name"
date: "10. Mai 2015"
output: beamer_presentation
---
## Slide 1
```{r}
knitr::current_input()
```
哪个编织完成了任务.
这篇关于.rmd文件的访问名称,并在R中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文