ferx_model_edit.RdOpens a .ferx model file for editing. If the file lives inside the
installed ferx package directory (i.e. a bundled read-only example), a copy
is written to dest first and that copy is opened instead.
ferx_model_edit(
path,
dest = ".",
overwrite = FALSE,
save_as = NULL,
.editor = utils::file.edit
)Path to a .ferx model file.
Directory to copy read-only package files into before editing.
Defaults to the current working directory. Ignored when path is
already a writable user-owned file.
Logical. If TRUE, overwrite an existing file in
dest when copying a package example. If FALSE (default) and
the destination file already exists, an error is raised.
Controls post-edit save-as behaviour:
NULL or FALSE (default) — no extra action after
editing. Accepting FALSE lets you pass expressions like
save_as = interactive().
TRUE — interactively prompt the user for a destination path.
A character string — silently copy the edited file to that path.
When a copy is made the copy path is returned; otherwise the edited file path is returned.
Function used to open the file. Defaults to
utils::file.edit. Override in tests or non-interactive contexts to
replace or suppress the editor call.
The path of the file in its final location, invisibly. When
save_as produces a copy, that copy's path is returned; otherwise
the path of the edited file is returned.
After the editor closes, an optional save_as step lets you copy the
edited file to a new path — useful when iterating on a model to keep
versioned copies.
if (FALSE) { # \dontrun{
ex <- ferx_example("warfarin")
# Edit a copy of the bundled example in a temp directory
my_model <- ferx_model_edit(ex$model, dest = tempdir())
# Edit a user-owned model directly
ferx_model_edit("my_model.ferx")
# After editing, save a copy to a new versioned path
ferx_model_edit("run1.ferx", save_as = "run2.ferx")
# After editing, interactively ask for the destination
ferx_model_edit("run1.ferx", save_as = TRUE)
} # }