save_model
Save a model to the outputs directory
Saves a fitted model object to the configured models directory. The directory is created lazily on first use.
Usage
save_model(model, name, format = "rds", public = FALSE, overwrite = TRUE, ...)
Arguments
| Argument | Description |
|---|---|
model
|
A fitted model object (lm, glm, tidymodels workflow, etc.) |
name
|
The name for the output file (without extension) |
format
|
Output format: "rds" (default) or "qs" (faster, requires qs package) |
public
|
If TRUE, saves to public outputs directory (for project_sensitive type) |
overwrite
|
If TRUE, overwrites existing files (default: TRUE) |
...
|
Additional arguments passed to the underlying save function |
Returns
The path to the saved file (invisibly)
Examples
# Fit and save a model
model <- lm(mpg ~ hp + wt, data = mtcars)
save_model(model, "mpg_regression")
# Save with qs for faster serialization
save_model(model, "mpg_regression", format = "qs")
Source: R/outputs.R