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" #' ---
#' A script comment that includes **markdown** formatting.
Rather than displaying as an R comment in the compiled notebook any
render calls the knitr spin function to convert the R script to an Rmd file. The spin function also enables you to add knitr chunk options with another special comment prefix (#+).Here's an example of a script that uses the various features of spin:
For more details on knitr::spin see the following documentation: