How to pass a list as an argument and how to apply abitrary set of lists as seperate arguments to function

Hi there,

I have a multitude of lists but not all containing the same number of lists you will see I have named them master_list_a and master_list_b.

I want to achieve two things:

  1. I want to know how to pass the first list as an argument into a function while passing all other lists as separate arguments into a function after the first.

  2. I want to find a simple way to rotate the first argument (so instead of a it becomes b) while passing all other lists then as separate arguments.

Any idea how to do this as cleanly as possible? I am not entirely sure if there is some way to do closure or some sort of quote/unquoting.

master_list_a <- list(
  a = sample(1:100,20),
  d = sample(1:100,20),
  e = sample(1:100,20),
  f = sample(1:100,20)
)

master_list_a
#> $a
#>  [1] 80 12 50 78 40 59 43 90 66 21 53  1 62 84 45 64  4 32 95 13
#> 
#> $d
#>  [1]  41  46 100  76  17  14  69  33  50  77   9  95  20  44  57  85  68   6  53
#> [20]  28
#> 
#> $e
#>  [1] 52 33 97  4 49 31 99 62 19 41 63 26 10 39 17  7 55 50  8 81
#> 
#> $f
#>  [1] 97 43 38 46 60  2 27  3 83 10 92 18 67 99 93 77 12 70 31 37


master_list_b <- list(
  d = sample(1:100,20),
  e = sample(1:100,20),
  f = sample(1:100,20)
)

master_list_b
#> $d
#>  [1]  20  53  31  57  36  43  72   6  93   2  29  68   4  41  14 100  40  97  44
#> [20]  35
#> 
#> $e
#>  [1] 70 14 38 89 58 98 36 16 12 32 11 42 22 61 60 85 90 57 30 20
#> 
#> $f
#>  [1] 26 82 24 28 36  8 19 15  5 27 17 52 39 47 10  7 23 41 25 92

Created on 2022-04-28 by the reprex package (v2.0.0)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.