View source: R/make_notebook.R
| make_notebook | R Documentation |
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.
make_notebook(
name,
type = NULL,
dir = NULL,
stub = "default",
overwrite = FALSE,
subdir = NULL
)
name |
Character. The file name. Extension determines type:
|
type |
Character. File type: "quarto", "rmarkdown", or "script". Auto-detected from extension if provided. If NULL (default):
|
dir |
Character. Directory to create the file in. Uses your project's
configured |
stub |
Character. Name of the stub template to use. Defaults to
"default". User can create custom stubs in |
overwrite |
Logical. Whether to overwrite existing file. Default FALSE. |
subdir |
Optional subdirectory under |
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.
Notebooks are created in the notebooks/ directory by default:
notebooks/ 1-data-cleaning.qmd 2-analysis.qmd 3-visualization.qmd
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
The function searches for stub templates in this order:
User stubs: stubs/notebook-{stub}.qmd or stubs/notebook-{stub}.Rmd
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)
Invisible path to created notebook
make_qmd(), make_rmd(), make_revealjs(), make_presentation()
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()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.