Given this_list and its index, determine a "divisor" and "modulus" instructing how to subset the character vector at that index given a particular array task index. Downstream, selecting this_list[[index]][[x]] for each index yields a combination of values that is unique across array indices. Here x = array_index / divisor % modulus. This is a helper function for job_loop.

get_list_indexing(this_list, index)

Arguments

this_list

A `list` of character vectors

index

integer(1) specifying the index of this_list to be subsetted downstream of this function

Value

A length-2 named list of integer(1) vectors containing a divisor and modulus

Author

Nicholas J. Eagles

Examples


array_task <- 5 # suppose this is the fifth task in an array job
index <- 2 # will refer to the 'feature' element of 'loops' below
loops <- list(
    region = c("DLPFC", "HIPPO"), feature = c("gene", "exon", "tx", "jxn")
)
indexing <- slurmjobs:::get_list_indexing(loops, index)
this_feature <- loops[[index]][[
    array_task %/% indexing$divisor %% indexing$modulus
]]
sprintf(
    'The %ith array task will have "%s" as its feature.',
    array_task,
    this_feature
)
#> [1] "The 5th array task will have \"gene\" as its feature."