knit .rmd file to .md and save the .md file one level up with a different name

I have a .rmd file called mycode.rmd saved in a subdirectory called root/scripts on github.

R Markdown
========================================================

I'd like to find a way to 'knit to HTML' in RStudio and have the resulting .md
file save one level up in the root directory with a different name, README.md, 
so Github will display it.

```{r, results='hide'}
math <- 1 + 1
```

This way README.md in the root folder will always be up to date with my 'real' .rmd file in root/scripts . The most I want to do to make this happen is press 'knit to HTML' from RStudio when working on mycode.rmd .

在这里输入图像描述

Update :

A solution based on comments from @Thomas:

Here is one option:

```{r, include=FALSE}
   # add this chunk to end of mycode.rmd
   file.rename(from="scripts/mycode.md", 
               to="README.md")
```

A solution based on comments from @Thomas:

Here is one option:

```{r, include=FALSE}
   # add this chunk to end of mycode.rmd
   file.rename(from="scripts/mycode.md", 
               to="README.md")
```
链接地址: http://www.djcxy.com/p/75562.html

上一篇: 为什么/何时需要重新打开ember.js中的类?

下一篇: 将.rmd文件编织为.md并将.md文件另存为一个不同的名称