I'm developing an R package, one of my package function is generate_report()
which generate an html report with rmarkdown using a templete Rmd file and function arguments:
#' generate report based on templete file
#' @import rmarkdown
#' @export
generate_report <- function(x, y){
rmarkdown::render('templete.Rmd', envir = list(x = x, y = y))
}
and here is the inst/templete.Rmd
file: (when the package is compiled, it will be moved to top-level folder of package:
---
title: "templete"
output: html_document
---
## Head 1
```{r}
print(x)
```
```{r}
print(y)
```
my question is, when the package is devtools::install()
ed, function generate_report()
can not find file templete.Rmd
, how to make the function find this templete.Rmd file in right way ?