A helper to generate named lists
multiplyList(source, pattern)
source | a named lists with the values to multiply |
---|---|
pattern | a vector of names defining how to construct a new list (typically, a longer one with replicates). |
a list
source <- list( total = 1, label = c(2,3), unlabel = c(4,5)) pattern <- c("total", "total", "label", "total", "unlabel") multiplyList(source, pattern)#> $total #> [1] 1 #> #> $total #> [1] 1 #> #> $label #> [1] 2 3 #> #> $total #> [1] 1 #> #> $unlabel #> [1] 4 5 #>