This function generates a hash value for a given list of arguments. It is designed to produce a consistent hash by optionally removing NA values, ordering arguments alphabetically, handling timestamp inclusion, etc.
Usage
generate_hash(
parameters_list,
hash_includes_timestamp = FALSE,
ignore_na = TRUE,
alphabetical_order = TRUE,
algo = "xxhash64",
ignore_script_name = FALSE
)
Arguments
- parameters_list
A named list of arguments for which the hash will be generated. Each element in the list should correspond to a parameter.
- hash_includes_timestamp
Logical; if FALSE, any timestamp included in parameters_list will be removed before hash generation. If TRUE, the timestamp will be included in the hash calculation.
- ignore_na
Logical; if TRUE, any NA values in parameters_list will be removed before hash generation.
- alphabetical_order
Logical; if TRUE, the arguments in parameters_list will be sorted alphabetically by their names before hash generation.
- algo
The hash algorithm to use (See
?digest
)- ignore_script_name
Logical. If
TRUE
, the script name is ignored during hash generation.
Examples
args <- list(param1 = "value1", param2 = 100, param3 = NA)
generate_hash(args)
#> $parameters_list
#> $parameters_list$param1
#> [1] "value1"
#>
#> $parameters_list$param2
#> [1] 100
#>
#>
#> $hash
#> [1] "84f90f1aa87f3610"
#>