make_notebook: Create a Notebook or Script from Stub Template

View source: R/make_notebook.R

make_notebookR Documentation

Create a Notebook or Script from Stub Template

Description

Creates a new Quarto (.qmd), RMarkdown (.Rmd) notebook, or R script (.R) from stub templates. Searches for user-provided stubs first (in ⁠stubs/⁠ directory), then falls back to framework defaults.

Usage

make_notebook(
  name,
  type = NULL,
  dir = NULL,
  stub = "default",
  overwrite = FALSE,
  subdir = NULL
)

Arguments

name

Character. The file name. Extension determines type:

  • .qmd: Quarto notebook (default if no extension)

  • .Rmd: RMarkdown notebook

  • .R: R script Examples: 1-init, 1-init.qmd, analysis.Rmd, script.R

type

Character. File type: "quarto", "rmarkdown", or "script". Auto-detected from extension if provided. If NULL (default):

  1. Checks config default_notebook_format (or legacy options$default_notebook_format)

  2. Falls back to "quarto" (Framework is Quarto-first)

dir

Character. Directory to create the file in. Uses your project's configured directories$notebooks setting. Default: "notebooks/".

stub

Character. Name of the stub template to use. Defaults to "default". User can create custom stubs in ⁠stubs/notebook-{stub}.qmd⁠, ⁠stubs/notebook-{stub}.Rmd⁠, or ⁠stubs/script-{stub}.R⁠.

overwrite

Logical. Whether to overwrite existing file. Default FALSE.

subdir

Optional subdirectory under dir (e.g., "analyses/exploratory").

Details

Convenient aliases: Use make_qmd() or make_rmd() for explicit Quarto or RMarkdown notebook creation. Use make_revealjs() or make_presentation() for reveal.js presentations.

Default Output

Notebooks are created in the ⁠notebooks/⁠ directory by default:

notebooks/
  1-data-cleaning.qmd
  2-analysis.qmd
  3-visualization.qmd

Extension Normalization

  • If name includes .qmd or .Rmd, type is auto-detected

  • If no extension provided, .qmd is used (Quarto-first)

  • Use type = "rmarkdown" to default to .Rmd

Stub Template Resolution

The function searches for stub templates in this order:

  1. User stubs: ⁠stubs/notebook-{stub}.qmd⁠ or ⁠stubs/notebook-{stub}.Rmd⁠

  2. Framework stubs: ⁠inst/stubs/notebook-{stub}.qmd⁠ or ⁠inst/stubs/notebook-{stub}.Rmd⁠

Custom stub templates can use placeholders:

  • {filename} - The notebook filename without extension

  • {date} - Current date (YYYY-MM-DD)

Value

Invisible path to created notebook

See Also

make_qmd(), make_rmd(), make_revealjs(), make_presentation()

Examples


if (FALSE) {
# Create notebooks/1-init.qmd (defaults to Quarto)
make_notebook("1-init")

# Create notebooks/analysis.Rmd (RMarkdown, extension-based)
make_notebook("analysis.Rmd")

# Explicit type parameter
make_notebook("report", type = "rmarkdown")

# Use custom stub template
make_notebook("report", stub = "minimal")

# Create in specific directory
make_notebook("explore", dir = "work")

# Convenient aliases (recommended for explicit types)
make_qmd("analysis")       # Always creates .qmd
make_rmd("report")         # Always creates .Rmd
make_revealjs("slides")    # Creates reveal.js presentation
make_presentation("deck")  # Alias for make_revealjs()
}



framework documentation built on Feb. 18, 2026, 1:07 a.m.