Skip to contents

List saved R sessions

Usage

list_jamsessions(
  sessions_path = jamsession_paths()$sessions,
  most_recent = FALSE,
  session_prefix = "^inProgress_",
  session_suffix = "[.]RData$",
  add_stats = FALSE,
  return_type = c("df", "sessions", "list"),
  ...
)

Arguments

sessions_path

character vector of one or more file paths to search for saved R sessions. When NULL, it uses the output from jamsession_paths()$sessions.

most_recent

logical default FALSE, whether to return only the most recent entry for each session name. When most_recent is FALSE all saved versions are returned for all R session names.

session_prefix, session_suffix

character string used as prefix or suffix when searching each path in sessions_path for matching file names.

add_stats

logical indicating whether to include summary stats for each session: number_saved is the number of past versions of the session; total_size is the total file size for all saved versions.

...

additional parameters are ignored

Value

data.frame by default, with sessions per row. When return_type='sessions' it returns the unique session names. When return_type='list' it returns a list with both elements.

Details

This function lists available saved R sessions, usually called by grep_jamsessions().

When most_recent=TRUE it returns only the most recent session based upon the save_date.

It is possible to supply multiple file paths using the argument sessions_path, in which case all sessions are returned for all directories, then they are sorted by save_date. The input sessions_path is stored as an ordered factor, such that two sessions with the same save_date will still be ordered consistent with the input directories in sessions_path. In this case, when most_recent=TRUE there will be one entry returned per object name, and the first entry will be the most recent entry ordered by save_date then sessions_path. In practice, it is recommended to use one sessions_path location, but this option exists.

For example, jamsession(grep_sessions("my_session")) will load the most recent session by save_date where any ties prefer the order in sessions_path. Similarly, load_jamsession("my_session") does the same thing, without the grep_patten search step.

See also

Examples

list_jamsessions();
#>                                             session save_date days_old
#> theo-grpeaks-jul2025_25jul2025 theo-grpeaks-jul2025 25jul2025      115
#>                                file_size
#> theo-grpeaks-jul2025_25jul2025    439 Mb
#>                                                                     session_path
#> theo-grpeaks-jul2025_25jul2025 C:/Users/james.ward/Documents/Projects/R-sessions
#>                                                                   session_file
#> theo-grpeaks-jul2025_25jul2025 inProgress_theo-grpeaks-jul2025_25jul2025.RData