search for saved R objects

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

character string with regular expression pattern, although usually any text substring will work. When grep_string contains multiple values, they are used in order to find matching object names, using jamba::provigrep(). The order typically has no effect, but can be used to retain the order of objects returned even when the objects have the same save_date.

save_date

character string or vector, used as a regular expression search for matching values in the save_date column output from list_objects(). It can be used to search for objects with a specific save_date. Remember to use most_recent=FALSE when 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 from jamsession_paths()$objects.

ignore.case

logical passed to grep() indicating whether to ignore upper and lower case, by default ignore.case=TRUE.

return_df

logical indicating whether to return a data.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

logical indicating whether to include summary stats for each object: number_saved is the number of past versions of the object; total_size is 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 also

Other jamsession objects: list_objects(), load_object(), save_object()

Examples

grep_objects(".");
#> object save_date #> gokeynmatlist250k_11feb2021 gokeynmatlist250k 11feb2021 #> all_samples_sle2_07jan2021 all_samples_sle2 07jan2021 #> count_test_24nov2020 count_test 24nov2020 #> jam_divergent_17nov2020 jam_divergent 17nov2020 #> jam_linear_17nov2020 jam_linear 17nov2020 #> dm_jdm_samples_df_12aug2020 dm_jdm_samples_df 12aug2020 #> dm_ab_list_11aug2020 dm_ab_list 11aug2020 #> dm_cbc_list_11aug2020 dm_cbc_list 11aug2020 #> dmjdm_ipa_pathways_30jul2020 dmjdm_ipa_pathways 30jul2020 #> arris_df_27jul2020 arris_df 27jul2020 #> proteinatlas_expr_fdb11_23jul2020 proteinatlas_expr_fdb11 23jul2020 #> proteinatlas_expression_fdb11_23jul2020 proteinatlas_expression_fdb11 23jul2020 #> proteinatlas_genesets_fdb11_23jul2020 proteinatlas_genesets_fdb11 23jul2020 #> gokey_data_06jul2020 gokey_data 06jul2020 #> my_df_12jun2020 my_df 12jun2020 #> my_df-my_df2_12jun2020 my_df-my_df2 12jun2020 #> arris_df-irow_11jun2020 arris_df-irow 11jun2020 #> mem_dmlupus_affysoma_plots_12apr2020 mem_dmlupus_affysoma_plots 12apr2020 #> dietrich_track_lines_l_10apr2020 dietrich_track_lines_l 10apr2020 #> dietrichTxiNames_20mar2020 dietrichTxiNames 20mar2020 #> dietrichTxis_20mar2020 dietrichTxis 20mar2020 #> days_old file_size #> gokeynmatlist250k_11feb2021 15 979 Mb #> all_samples_sle2_07jan2021 50 314 bytes #> count_test_24nov2020 94 539 kb #> jam_divergent_17nov2020 101 1.3 kb #> jam_linear_17nov2020 101 619 bytes #> dm_jdm_samples_df_12aug2020 198 475 bytes #> dm_ab_list_11aug2020 199 764 kb #> dm_cbc_list_11aug2020 199 22 kb #> dmjdm_ipa_pathways_30jul2020 211 75 kb #> arris_df_27jul2020 214 852 kb #> proteinatlas_expr_fdb11_23jul2020 218 5 Mb #> proteinatlas_expression_fdb11_23jul2020 218 5.3 Mb #> proteinatlas_genesets_fdb11_23jul2020 218 109 kb #> gokey_data_06jul2020 235 1.6 Mb #> my_df_12jun2020 259 160 bytes #> my_df-my_df2_12jun2020 259 212 bytes #> arris_df-irow_11jun2020 260 294 kb #> mem_dmlupus_affysoma_plots_12apr2020 320 299 kb #> dietrich_track_lines_l_10apr2020 322 1 kb #> dietrichTxiNames_20mar2020 343 345 bytes #> dietrichTxis_20mar2020 343 51 Mb #> object_path #> gokeynmatlist250k_11feb2021 /Users/wardjm/Projects/R-objects #> all_samples_sle2_07jan2021 /Users/wardjm/Projects/R-objects #> count_test_24nov2020 /Users/wardjm/Projects/R-objects #> jam_divergent_17nov2020 /Users/wardjm/Projects/R-objects #> jam_linear_17nov2020 /Users/wardjm/Projects/R-objects #> dm_jdm_samples_df_12aug2020 /Users/wardjm/Projects/R-objects #> dm_ab_list_11aug2020 /Users/wardjm/Projects/R-objects #> dm_cbc_list_11aug2020 /Users/wardjm/Projects/R-objects #> dmjdm_ipa_pathways_30jul2020 /Users/wardjm/Projects/R-objects #> arris_df_27jul2020 /Users/wardjm/Projects/R-objects #> proteinatlas_expr_fdb11_23jul2020 /Users/wardjm/Projects/R-objects #> proteinatlas_expression_fdb11_23jul2020 /Users/wardjm/Projects/R-objects #> proteinatlas_genesets_fdb11_23jul2020 /Users/wardjm/Projects/R-objects #> gokey_data_06jul2020 /Users/wardjm/Projects/R-objects #> my_df_12jun2020 /Users/wardjm/Projects/R-objects #> my_df-my_df2_12jun2020 /Users/wardjm/Projects/R-objects #> arris_df-irow_11jun2020 /Users/wardjm/Projects/R-objects #> mem_dmlupus_affysoma_plots_12apr2020 /Users/wardjm/Projects/R-objects #> dietrich_track_lines_l_10apr2020 /Users/wardjm/Projects/R-objects #> dietrichTxiNames_20mar2020 /Users/wardjm/Projects/R-objects #> dietrichTxis_20mar2020 /Users/wardjm/Projects/R-objects #> object_file #> gokeynmatlist250k_11feb2021 gokeynmatlist250k_11feb2021.RData #> all_samples_sle2_07jan2021 all_samples_sle2_07jan2021.RData #> count_test_24nov2020 count_test_24nov2020.RData #> jam_divergent_17nov2020 jam_divergent_17nov2020.RData #> jam_linear_17nov2020 jam_linear_17nov2020.RData #> dm_jdm_samples_df_12aug2020 dm_jdm_samples_df_12aug2020.RData #> dm_ab_list_11aug2020 dm_ab_list_11aug2020.RData #> dm_cbc_list_11aug2020 dm_cbc_list_11aug2020.RData #> dmjdm_ipa_pathways_30jul2020 dmjdm_ipa_pathways_30jul2020.RData #> arris_df_27jul2020 arris_df_27jul2020.RData #> proteinatlas_expr_fdb11_23jul2020 proteinatlas_expr_fdb11_23jul2020.RData #> proteinatlas_expression_fdb11_23jul2020 proteinatlas_expression_fdb11_23jul2020.RData #> proteinatlas_genesets_fdb11_23jul2020 proteinatlas_genesets_fdb11_23jul2020.RData #> gokey_data_06jul2020 gokey_data_06jul2020.RData #> my_df_12jun2020 my_df_12jun2020.RData #> my_df-my_df2_12jun2020 my_df-my_df2_12jun2020.RData #> arris_df-irow_11jun2020 arris_df-irow_11jun2020.RData #> mem_dmlupus_affysoma_plots_12apr2020 mem_dmlupus_affysoma_plots_12apr2020.RData #> dietrich_track_lines_l_10apr2020 dietrich_track_lines_l_10apr2020.RData #> dietrichTxiNames_20mar2020 dietrichTxiNames_20mar2020.RData #> dietrichTxis_20mar2020 dietrichTxis_20mar2020.RData
grep_objects("df");
#> object save_date days_old file_size #> dm_jdm_samples_df_12aug2020 dm_jdm_samples_df 12aug2020 198 475 bytes #> arris_df_27jul2020 arris_df 27jul2020 214 852 kb #> my_df_12jun2020 my_df 12jun2020 259 160 bytes #> my_df-my_df2_12jun2020 my_df-my_df2 12jun2020 259 212 bytes #> arris_df-irow_11jun2020 arris_df-irow 11jun2020 260 294 kb #> object_path #> dm_jdm_samples_df_12aug2020 /Users/wardjm/Projects/R-objects #> arris_df_27jul2020 /Users/wardjm/Projects/R-objects #> my_df_12jun2020 /Users/wardjm/Projects/R-objects #> my_df-my_df2_12jun2020 /Users/wardjm/Projects/R-objects #> arris_df-irow_11jun2020 /Users/wardjm/Projects/R-objects #> object_file #> dm_jdm_samples_df_12aug2020 dm_jdm_samples_df_12aug2020.RData #> arris_df_27jul2020 arris_df_27jul2020.RData #> my_df_12jun2020 my_df_12jun2020.RData #> my_df-my_df2_12jun2020 my_df-my_df2_12jun2020.RData #> arris_df-irow_11jun2020 arris_df-irow_11jun2020.RData