This function creates a restore point for the current development environment , allowing you to save the state of your workspace for future restoration.

workspace_save(
  note = "",
  .dir = getOption("workspace.dir", "_workspace"),
  n_threads = 2,
  is_interactive = interactive()
)

Arguments

note

Character. Default "". An optional note to add to the restore point, providing additional context or information.

.dir

Character. Default getOption("workspace.dir", "_workspace"). Directory path to save workspace files.

n_threads

Integer. Default 2. The number of threads to use for the saving process.

is_interactive

Logical. Default interactive(). This parameter is used for package development purposes only, and it is recommended to avoid changing this setting.

Value

File path of the newly created workspace file, invisibly.

Details

The workspace_save() function creates a restore point for the current development environment. If this is the first time the function is executed in a development environment, it performs the following actions:

  1. Create '_workspace' Folder: It creates a folder named '_workspace' in the current working directory if it doesn't already exist

  2. Ignore '_workspace' in Version Control: It adds '_workspace' to the '.gitignore' and '.Rbuildignore' files. This ensures that the folder is excluded from version control and building processes

  3. Generate Restore Point File: It generates a restore point file with a filename following the pattern 'workspace/ws-YYYY-MM-DD-HH-MM-SSOPTIONAL NOTE.qs'

    • YYYY-MM-DD-HH-MM-SS represents the date and time of the restore point creation

    • OPTIONAL NOTE corresponds to the optional note provided as a parameter to the function

  4. Output Log Messages: The function outputs log messages to provide feedback on the execution status of each step

    • Log messages starting with a green 'v' indicate successful operations

See also

Other workspace functions: workspace_restore()

Examples

if (FALSE) {
# Default
workspace_save()

# Add a note
workspace_save("lm model")
}