Files that don't fall into the usual directories of an R package can go in the inst directory. Hadley Wickham gives a good overview of the purpose and usage for that directory in his R Packages text. In short:
- A package should only have standard files in the top directory.
- Files that don't go in the top level or usual directories can go in the
inst directory.
- When creating a built package, everything from
inst is copied to the top level of the bundle.
- You can get the path to any file in a package using the
system.file() function.
For your case, I'd suggest a directory structure like this (items ending with / are directories):
mypackage
├ R/
├ inst/
| └ templates/
| └ mypath.Rmd
├ DESCRIPTION
├ NAMESPACE
└ ... # other stuff
If you'd build this package, the bundled version's structure would look like this:
mypackage.tar.gz
├ R/
├ templates/
| └ mypath.Rmd
├ DESCRIPTION
├ NAMESPACE
└ ... # other stuff
Then, you can reference the file in your package like this:
make_report <- function(...) {
rmd_path <- system.file("templates", "mypath.Rmd", package = "mypackage")
rmarkdown::render(input = rmd_path, params = list(...))
}
The official documentation, Writing R Extensions, describes inst and other subdirectories in more detail.