2013-11-14 53 views
6

我有一個.rmd文件,名爲mycode.rmd,保存在名爲root/scripts的子目錄github上。將.rmd文件編織爲.md並將.md文件另存爲一級別

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

這樣README.md在根文件夾將永遠是最新與我的「真正的」 .rmd文件中root/scripts。我想要做的最多的事情是在mycode.rmd上工作時,從RStudio按'編織爲HTML'。

enter image description here

更新

根據意見從@Thomas A液:

Here is one option: 

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

雖然不是在'knit'之後用'file.rename'移動它? – Thomas

+0

...或指定一個目錄級別的輸出文件路徑? – Thomas

+0

現在查看file.rename。你能爲knitr指定一個輸出文件路徑,它將控制編織到html時md文件的保存位置嗎?我以爲你只能指定圖形路徑。 –

回答

3

根據意見從@Thomas A液:

這裏是一個選項:

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