I have an R package with a boilerplate RMD file that I include. I would like to write a function to let the user retrieve this file, something like:
SaveDefaultMarkdown(destination = 'myFile.rmd')
The function would locate the file within my package and copy it to target location. I currently have this file saved in ./inst/rmd/markdown.rmd. Is there a robust way for code within the R package to find this file? Is there a different/preferred mechanism to include and deliver a file like this?
A function wrapping around system.file("rmd/myFile.Rmd", package = "mypackage") should be good enough. All of the content inside inst/ is moved to the top-level of the package when it is built/installed, so you can use system.file() as shown above to retrieve files within packages.
You could wrap this function with something like rstudioapi::navigateToFile() to open it interactively. Lots of possibilities.
EDIT: For completeness, if this is a template Rmd file, of sorts, you can make it a selectable template in the File > New File > R Markdown > From Template window without too much work. See here and here for more details.