Notebooks & Scripts
make_script()
Create an R Script from Stub Template
Convenience wrapper for make_notebook() that creates R scripts (.R files). This is identical to calling make_notebook("name.R").
Usage
make_script(name, dir = NULL, stub = "default", overwrite = FALSE)
Arguments
- name
- Character. The script name (with or without .R extension). Examples: "process-data", "process-data.R"
- dir
- Character. Directory to create the script in. Uses your project's configured `directories$scripts` setting. Default: "scripts/".
- stub
- Character. Name of the stub template to use. Defaults to "default". User can create custom stubs in `stubs/script-{stub}.R`.
- overwrite
- Logical. Whether to overwrite existing file. Default FALSE.
Value
Invisible path to created script
Details
This function is a convenience wrapper that:
- Ensures the name ends with .R extension
- Uses
script_dirconfig option instead ofnotebook_dir - Calls
make_notebook()withtype = "script"Default Output
Scripts are created in the scripts/ directory by default:
scripts/
process-data.R
build-features.R
run-model.R
Examples
if (FALSE) {
# Create script (extension optional)
make_script("process-data")
make_script("process-data.R")
# Use custom stub
make_script("etl-pipeline", stub = "etl")
# Create in specific directory
make_script("analysis", dir = "analysis/")
}