search for saved R objects
Usage
grep_objects(
grep_string = ".",
save_date = ".",
objects_path = jamsession_paths()$objects,
ignore.case = TRUE,
return_df = TRUE,
most_recent = TRUE,
add_stats = FALSE,
verbose = FALSE,
...
)Arguments
- grep_string
characterstring with regular expression pattern, although usually any text substring will work. Whengrep_stringcontains multiple values, they are used in order to find matching object names, usingjamba::provigrep(). The order typically has no effect, but can be used to retain the order of objects returned even when the objects have the samesave_date.- save_date
characterstring or vector, used as a regular expression search for matching values in thesave_datecolumn output fromlist_objects(). It can be used to search for objects with a specificsave_date. Remember to usemost_recent=FALSEwhen searching for past versions of stored R objects.- objects_path
character vector of one or more file paths to search for saved R objects. When
objects_path=NULL, it uses the output fromjamsession_paths()$objects.- ignore.case
logicalpassed togrep()indicating whether to ignore upper and lower case, by defaultignore.case=TRUE.- return_df
logicalindicating whether to return adata.frame.- most_recent
logical whether to return only the most recent saved version of each matching object, by default
most_recent=TRUE. Note that it returns the most recent of each matching object.- add_stats
logicalindicating whether to include summary stats for each object:number_savedis the number of past versions of the object;total_sizeis the total file size for all saved versions.- verbose
logical whether to print verbose output
- ...
additional arguments are passed to
grepl().
Value
data.frame when return_df=TRUE; character vector
when return_df=FALSE. The returned data will contain object
names that match the grep_string input.
Details
This function searches for saved R objects using one or more text or regular expression patterns.
It is possible to supply multiple file paths using the
argument objects_path, in which case all objects are returned
for all directories, then they are sorted by save_date.
The input objects_path is stored as an ordered factor, such
that two files with the same save_date will still be ordered
consistent with the input directories in objects_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 objects_path.
In practice, it is recommended to use one objects_path
location, but this option exists.
For example, load_object(grep_objects("my_favorite_object"))
will load the most recent object by save_date where any
ties prefer the order in objects_path. Similarly,
load_object("my_favorite_object") does the same thing,
without the grep_patten search step.
See save_object() for examples.
See also
Other jamsession objects:
load_object(),
save_object()