Search for saved R sessions
Usage
grep_jamsessions(
pattern,
sessions_path = jamsession_paths()$sessions,
return_df = TRUE,
sort_by_date = TRUE,
ignore.case = TRUE,
most_recent = TRUE,
include_attrs = FALSE,
add_stats = FALSE,
remove_pattern = NULL,
replacement = NULL,
verbose = FALSE,
...
)Arguments
- pattern
chracter pattern used with
grep()to match session names.- sessions_path
character vector of one or more file paths to search for saved R sessions. When
NULL, it uses the output fromjamsession_paths()$sessions.- return_df
logical whether to return a vector (FALSE) or data.frame (TRUE) with detailed information about each session.
- sort_by_date
logical whether to sort results by date, as opposed to the order retrieved from
list.files.- ignore.case
logical sent to
grep, by default TRUE which searches in case-insensitive mode.- most_recent
logical whether to return only the most recent saved version of each matching session, by default
TRUE. This argument is passed tolist_jamsessions().- include_attrs
logical indicating whether to include attributes
"file_path","file_size","save_date", and"days_old", only used whenreturn_df=FALSE.- add_stats
logicalindicating whether to include summary stats for each session:number_savedis the number of past versions of the session;total_sizeis the total file size for all saved versions.- remove_pattern, replacement
arguments passed to
clean_jamsession_name().- verbose
logicalindicating whether to print verbose output.- ...
additional arguments are passed to
list_jamessions(), andjamba::provigrep(), as relevent. Ifsession_prefixorsession_suffixshould be customized, it should be done here.
Details
This function searches for saved R sessions using one or more text or regular expression patterns.
See list_jamsessions() for more details about stored sessions.
This function can be chained with load_jamsession(), for
example load_jamsession(grep_jamsessions("my_project")),
and it will load the most recently saved R session.
See also
Other jamsession sessions:
load_jamsession(),
save_jamsession(),
show_session_versions()
Examples
grep_jamsessions(".");
#> session save_date days_old file_size
#> theo-grpeaks-jul2025 theo-grpeaks-jul2025 25jul2025 115 439 Mb
#> session_path
#> theo-grpeaks-jul2025 C:/Users/james.ward/Documents/Projects/R-sessions
#> session_file
#> theo-grpeaks-jul2025 inProgress_theo-grpeaks-jul2025_25jul2025.RData