To compile a notebook from an R script you simply pass the script to render
. For example:
rmarkdown::render("analysis.R")
rmarkdown::render("analysis.R", "pdf_document")
The first call to render
creates an HTML document, whereas the second creates a PDF document. By default the name of the script, username, and current date and time are included in the header of the generated notebook. You can override this default behavior by including explicit metadata in a specially formatted R comment: #' ---
#' title: "Crop Analysis Q3 2013"
#' author: "John Smith"
#' date: "May 3rd, 2014"
#' ---