Search code examples
rrstudiogithub-pages

How to convert .Rmd into .md in R studio?


I am working on a website with Rmarkdown on gh-pages. However, in R studio you can only create new .Rmd files. This is a problem because I need to convert my .Rmd files into .md files before I push to my github repo.

Does anyone have some advice?


Solution

  • Since you're using RStudio, I'll refer to the documents they provide. Specifically, Markdown Documents, accessible by clicking on the question mark pull-down next to "Knit", select "Using R Markdown" which takes you to their webpage. From there, select "Formats > Markdown".

    That page shows you that if you include the following in the YAML (first lines of the document, different kind of meta/markup as markdown), the output will be a .md file:

    ---
    title: "Habits"
    author: John Doe
    date: March 22, 2005
    output: md_document
    ---
    

    (The only relevant part is the output: portion.) In fact, since you mentioned gh-pages, you may (though not necessarily) want to choose the github-flavor of markdown with this instead:

    ---
    title: "Habits"
    author: John Doe
    date: March 22, 2005
    output:
      md_document:
        variant: markdown_github
    ---
    

    From here, click on the "Knit" button and you will get your .Rmd-to-.md conversion.