Create an empty Rmd file (no popup menu, no template)

Hi all,

To create an empty Rmd file, you either have to go through the popup menu every time and subsequently delete everything in the created file, or create a different filetype and then save as .Rmd. The latter option gives a warning when doing so with an Rscript.

How can one create an empty Rmd file (i.e. to create questions with help of the exams package) in a straightforward manner?

Thank you in advance

There's a chance I misunderstood your question, but you can do the following:

  1. Open a blank R script (use Ctrl + Shift + N ).
  2. Change file type (this may not be the correct terminology, but I hope you can understand what I mean) to R Markdown from the option in the bottom right corner of the source pane.
  3. Edit the file as you wish and save it. It'll be saved as a .Rmd file by default.

You understood the question perfectly. Thanks for the tip, I've overlooked that little corner all my life. It does make the process smoother for sure. If you'd know how I can do this with a shortcut, that would be totally awesome. But as far as I could find, that's not a possibility (yet).

Another option to this could be to edit the template file, depending on your OS the path would be different but as reference in windows is located here C:\Program Files\RStudio\resources\templates\r_markdown_v2.Rmd

1 Like

You can also create the file directly with R code, e.g.


If the requested file path does not exist, it will be created and the appropriate editing mode will be inferred from the file extension as per usual. (although note that the file's parent directory must already exist)

In theory, you could also build an RStudio Addin that accomplished this for you, with a shortcut and perhaps some minimal UI for selecting a file path.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.