template_rmd: Create a template script-file

Description Usage Arguments Note Author(s)

Description

This function will create an R or Rmd-file (depending on the file extension of the input) including some predefined lines. The function is designed to save some time writing the same input again and again (e.g. Author, date and other things). By using this template all warnings and messages will be written to a file ('filename_warnings.Rout') and errors will interupt rendering.

Usage

1
2
3
template_rmd(file, Author = Sys.info()["effective_user"],
  Date = "`r Sys.Date()`", open = TRUE, doctype = "html",
  knitr_sidecar = FALSE)

Arguments

file

Character. Specify the path to save the new file. Use relative file paths and specify the file extension; e.g. 'filesnew_dir/myfile.Rmd'. or 'in/src/new_dir/myfile.R'. If the extension is neither .R nor .Rmd (e.g. no extension) an .R-extension will be added by default.

Author

Character. Optionally customize the name of the Author (used for the YAML header). Default is the effective user of the system info.

Date

Character. Optionally customize the date (used for the YAML header). Default is the current Date (format YYYY-MM-DD).

open

Logical. If TRUE the file will be opened (via 'file.edit“).

doctype

Character. Specify file extension for different output formats of Rmd-files (pdf, html, docx).

knitr_sidecar

Logical. Write sidecar file for knitr-setup?

Note

Missing directories will be created recursively.

It is not possible to overwrite existing files.

Other YAML header options will be choosen automatically. Edit the resulting file to customize the YAML header.

R files will be ready to be spinned via knitr. Therefore the script contains some preceding roxygen comments.

Author(s)

Frederik Sachser


sachserf/framework documentation built on May 29, 2019, 12:21 p.m.