Notebooks & Scripts
make_notebook()
Create a Notebook or Script from Stub Template
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").
Value
Invisible path to created notebook
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
.qmdor.Rmd, type is auto-detected - If no extension provided,
.qmdis used (Quarto-first) - Use
type = "rmarkdown"to default to.Rmd
Stub Template Resolution
The function searches for stub templates in this order:
- User stubs:
stubs/notebook-{stub}.qmdorstubs/notebook-{stub}.Rmd - Framework stubs:
inst/stubs/notebook-{stub}.qmdorinst/stubs/notebook-{stub}.Rmd
Custom stub templates can use placeholders:
{filename}- The notebook filename without extension{date}- Current date (YYYY-MM-DD)
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()
}