I need to automate some report generation. I would like to create an rmarkdown report from a function, something like
make_report <- function(file_path = "data_file.txt", outfile){
# get data from external file
object <- parse_text(file_path)
# ?pass it into report template?
rmarkdown::render("report_template.Rmd", outfile)
}
Where report_template.Rmd prints tables and figures based on the information in the data_frame object. I've seen ways to make rmarkdown templates, but I don't know if there is a way to pass anything into them.
You cannot directly pass objects to render function, but you still can save objects into RDS/csv and load them in your rmarkdown file at the beginning in the hidden section, so it will not be printed to your output document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With