Create a Table of the Parameters for Saved Results from RDS Files
Source:R/create_hash_table.R
create_hash_table.Rd
Reads in all the parameter files for a give folder, flattens nested lists, and then combines the parameters into a data frame. Each row in the resulting data frame represents the arguments used for one RDS file, identified by its hash. Optionally, the function can filter the data frame based on specified criteria and save it to a file.
Arguments
- folder
A string specifying the directory containing the RDS files.
- save_path
An optional string specifying the path to save the resulting hash table as a CSV file. If
NULL
, the hash table is not saved.- filter_list
An optional list of filters to apply to the hash table. Each element of the list should be named according to a column in the hash table and contain the value to filter for in that column.
Value
A data frame where each row corresponds to an parameters_list
from an RDS file,
with an additional column for the hash of each set of arguments.
Details
Saving the hash table can be helpful for the manipulation of parameters (see ?update_hash_table
)
or for removal of unwanted results (see ?cleanup_from_hash_table
).
Examples
## Setup
tmp_dir <- file.path(tempdir(), "example")
dir.create(tmp_dir)
## Save objects
obj1 <- rnorm(1000)
obj2 <- data.frame(
x = runif(100),
y = "something",
z = rep(c(TRUE, FALSE), 50)
)
obj3 <- list(obj1, obj2)
params1 <- list(
distribution = "normal",
other_params = list(param1 = TRUE, param2 = 1, param3 = NA)
)
params2 <- list(
distribution = "uniform",
other_params = list(param1 = FALSE, param2 = 2, param3 = "1", param4 = 4)
)
params3 <- list(
distribution = "composite",
other_params = list(param1 = TRUE, param2 = 3, param3 = 1)
)
save_objects(tmp_dir, obj1, params1)
save_objects(tmp_dir, obj2, params2)
save_objects(tmp_dir, obj3, params3)
## Create hash table (and save it)
create_hash_table(tmp_dir, save_path = file.path(tmp_dir, "hash_table.csv"))
#> distribution other_params[[param1]] other_params[[param2]]
#> 1 normal TRUE 1
#> 2 uniform FALSE 2
#> 3 composite TRUE 3
#> other_params[[param3]] script_name
#> 1 <NA> 4918b77f-ae69-4ae2-bea4-07e6f6a89e41
#> 2 1 4918b77f-ae69-4ae2-bea4-07e6f6a89e41
#> 3 1 4918b77f-ae69-4ae2-bea4-07e6f6a89e41
#> timestamp hash other_params[[param4]]
#> 1 2025-07-23 13:23:35 b4d0ab79d10e4e7b <NA>
#> 2 2025-07-23 13:23:35 40650b573a1cf710 4
#> 3 2025-07-23 13:23:35 3ad8d8534a75f850 <NA>
## Cleanup
unlink(tmp_dir, recursive = TRUE)