MUCollective / multiverse

R package for creating explorable multiverse analysis
https://mucollective.github.io/multiverse/
GNU General Public License v3.0
62 stars 5 forks source link

Should we be able to pass a list to branch which can be expanded as options? #88

Closed abhsarma closed 4 years ago

abhsarma commented 4 years ago

Could it be useful if we provide a list to branch as argument and it expands the list to create a set of options?

mjskay commented 4 years ago

is this different from what the .options argument does?

abhsarma commented 4 years ago

kinda?? I see the .options as a way to use indexing to get around this problem as it only expands sequences currently? Maybe .options can be expanded to also support lists and values in a list?

mjskay commented 4 years ago

To make things concrete, something like:

branch("param", .options = list("option1" ~ 1, "option2" ~ 2))

Should be equivalent to:

branch("param", "option1" ~ 1, "option2" ~ 2)

And this:

branch("param", .options = c(1,2,3))

Is equivalent to:

branch("param", 1,2,3)

?

If this is the case than both vectors and lists are covered by having .options just expand out whatever it is passed into arguments. That makes for a nice, simple rule that covers both cases?

abhsarma commented 4 years ago

yes I was thinking of something along those lines. I think Alex was trying to do write up some code for some meta-analysis which requires considering all possible (permuted) subsets of a set of studies, and declaring that within a branch statement is more difficult than if you have a list (from say gtools::permutations) which would create it for you, and branch could create a universe for each item in the list.

So we should have this?

mjskay commented 4 years ago

yeah definitely! I just assumed the existing .options implementation already was this :)