Skip to contents

save an R session

Usage

save_jamsession(
  session = get("session", envir = envir),
  save_date = jamba::getDate(),
  assign_session = FALSE,
  do_timestamp = TRUE,
  sessions_path = jamsession_paths()$sessions,
  do_prompt = TRUE,
  do_window_title = TRUE,
  save_history = TRUE,
  envir = globalenv(),
  session_prefix = "inProgress_",
  session_suffix = ".RData",
  save_objectlist = TRUE,
  objectlist_suffix = ".objectlist.txt",
  verbose = TRUE,
  ...
)

Arguments

session

character session name used to name the .RData file

assign_session

logical default FALSE, whether to assign 'session' in the global environment .GlobalEnv, to the session.

do_timestamp

logical default TRUE, whether to run utils::timestamp() so the current time and date are written into the .Rhistory file.

sessions_path

character vector of one or more file paths to search for saved R sessions. Default uses jamsession_paths()$sessions.

do_prompt

logical default TRUE, whether to run jamba::setPrompt() to set the R prompt to include the session name.

do_window_title

logical default TRUE, whether to update the graphics device options to include the session name in the title. When TRUE, it calls quartz.options(), X11.options(), and windows.options() if possible.

save_history

logical default TRUE, whether to save the R command history into an .Rhistory file. Note that the full available R command history is saved, but this command history is subject to platform-specific limitations, and thus may not contain the entire R command history.

envir

R environment to save, by default the active global environment globalenv().

session_prefix

character, default 'inProgress_' used to identify jamsession files distinct from other 'RData' files.

session_suffix

character default '.RData' used to define the filename extension.

save_objectlist

logical default TRUE, whether to save a character list of objects to a separate file, so they can be searched instead of loading the entire RData file for this information.

verbose

logical whether to print verbose output.

...

additional arguments passed to base::save()

date

character date string to use when naming the .RData file. By default the current date is used, called by jamba::getDate().

Details

This function saves the current R session to a .RData file, and the R history to a .Rhistory file. It saves these files to the first write-accessible path in sessions_path.

When envir is defined as something other than globalenv(), only the R objects stored in that environment are saved. However the R objects are saved as R objects, with no information about the source environment.

This function may assign the global variable 'session' to the name of the session loaded, but is not done by default due to assign_session=FALSE.

See also

Other jamsession sessions: grep_jamsessions(), load_jamsession(), show_session_versions()