Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile R Script to markdown

Using RStudio's "Compile Notebook to html" feature, I noticed that a temporary .md file was created in the process, but deleted automatically. At one point I was lucky enough to see its content, and it is exactly what I need: the code chunks alternate with output chunks, all perfectly formatted.

So my question is: how do I generate such an .md file directly form an R script?

like image 926
Dominic Comtois Avatar asked Jun 09 '14 21:06

Dominic Comtois


2 Answers

You could also run knitr::spin() directly from the R console.

like image 183
Ben Bolker Avatar answered Sep 29 '22 12:09

Ben Bolker


You could open an R Markdown file in RStudio and paste all of your code into it. Just make sure your code is inside an R chunk:

```{r}

Your code

```

Then click "knit HTML" and a .md file will be created and saved in your working directory.

like image 41
eipi10 Avatar answered Sep 29 '22 11:09

eipi10