Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

enter image description here

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")
```
like image 511
Eric Green Avatar asked Nov 14 '13 22:11

Eric Green


1 Answers

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")
```
like image 129
Eric Green Avatar answered Nov 10 '22 05:11

Eric Green