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
| Argument | Description |
|---|---|
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 |
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. |
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
Returns
Invisible path to created script
Examples
# 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/")
See Also
Source: R/make_script.R