Learn R Programming

rmarkdown (version 1.10)

draft: Create a new document based on a template

Description

Create (and optionally edit) a draft of an R Markdown document based on a template.

Usage

draft(file, template, package = NULL, create_dir = "default", edit = TRUE)

Arguments

file

File name for the draft

template

Template to use as the basis for the draft. This is either the full path to a template directory or the name of a template directory within the rmarkdown/templates directory of a package.

package

(Optional) Name of package where the template is located.

create_dir

TRUE to create a new directory for the document (the "default" setting leaves this behavior up to the creator of the template).

edit

TRUE to edit the template immediately

Value

The file name of the new document (invisibly).

Details

The draft function creates new R Markdown documents based on templates that are either located on the filesystem or within an R package. The template and its supporting files will be copied to the location specified by file.

Examples

Run this code
# NOT RUN {
rmarkdown::draft("Q4Report.Rmd",
                 template="/opt/rmd/templates/quarterly_report")

rmarkdown::draft("Q4Report.Rmd",
                 template="quarterly_report", package="pubtools")
# }

Run the code above in your browser using DataLab