New R notebook default template "notebook_osx.rmd"

New notebook can be created via Rstudio->File->New File->R Notebook. This opens a default notebook with some prefilled texts/chunks.

Earlier I need to edit the default template located at "/Applications/RStudio.app/Contents/Resources/resources/templates" with my edited version of "notebook_osx.Rmd".

I do not see this path in the current version of RStudio [RStudio 2022.12.0+353 Elsbeth Geranium Release]
So where can I edit the default new notebook template to suit my requirements.

This is on the following config.
"RStudio 2022.12.0+353 "Elsbeth Geranium" Release" on "MacOS Monterey"

I don't see an option to do this. Of course, they are embedded somewhere within the /Applications/RStudio.app file tree, but if it were me, I'd use a snippet manager, such as espanso and CMD A insert snip.

Bingo!
Thank you for the "they are embedded somewhere within the /Applications/RStudio.app file tree" :grinning:

Found it at '/Applications/RStudio.app/Contents/Resources/app/resources/templates' . They added another folder "app" to the earlier path.

Thank, problem solved.

1 Like

Just keeping this here in case it helps other users.

I have a executable that copies my personal & edited "notebook_osx.Rmd" to the path
"/Applications/RStudio.app/Contents/Resources/resources/templates".

In the edited "notebook_osx.Rmd" I have added some chunks, imports libraries I use most often etc.... saves time to retype all the commands ! :slightly_smiling_face:

So every time I create a new R Notebook it opens reformatted as per my edited template.

FWIW, you don't need to edit RStudio's copy! You can put that in ~/.config/rstudio/templates instead on macOS.

1 Like

Can you pls reconfirm on this since my laptop(Mac OSMonterrey) did not have the template folder. I created the folder and saved my edited "notebook_osx.Rmd" in it and it does not load the template.

RStudio still used the "rmd" from the "Application..." folder

I deleted the "notebook.rmd & notebook_osx.Rmd" from "/Applications/RStudio.app/Contents/Resources/resources/templates" and it did not load any template but a blank file.

I created

~/.config/rstudio/templates

and saved a copy of the default notebook.Rmd there with a change to the title to show that it had come from that location, rather than the default path

/Applications/RStudio.app/Contents/Resources/app/resources/templates

which was created by the installation of RStudio.app (I didn't do that manually).

Creating a new notebook uses the template from ~/.config/rstudio/templates. Opening an existing notebook shows whatever template it was created with.

Any template applied by the new notebook file option has to be named notebook.rmd; notebook_osx.Rmd won't work.

1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.