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

Accessing variables from each universe in a multiverse using extract_variables #74

Closed abhsarma closed 4 years ago

abhsarma commented 4 years ago

With the previous multiverse table structure, where all the stuff related to a single universe analysis runs in a single environment, we had the following workflow for extracting a variable (say x) #63 :

expand(M) %>%
  mutate(transformed_duration = map(.results, "x"))

With the new dictionary structure, we are creating the result of expand on the fly from the bottom level of the tree, but it does not have a column of environments (formerly .results). I don't see the point of providing that environment because it will only contain stuff from the last code block

anyway, this complicates the design of the extract_variables function and I am not sure what to do...

abhsarma commented 4 years ago
mjskay commented 4 years ago

if the parent environments are set up correctly using get() on the last environment will search up the tree automatically for you (whereas $ does not). So you should be able to implement extract_variables with get (or mget with inherits = TRUE)

abhsarma commented 4 years ago

Right, that's what I am using for the $ function for accessing stuff. But the question is should the output of expand(M) have a .results column which is the list of universe environments from the bottom level of the tree? I don't think that's very useful to expose it because it has even less use now for a user?

If we decide not to expose it, then the notion of extracting variables from the multiverse_table might not work, but you'd have to do it from the multiverse object itself. Does this make sense?

mjskay commented 4 years ago

I think you could leave the .results column in if you update extract_variables to use get() instead of $, because then it will still be useful?

abhsarma commented 4 years ago

Yeah, could do that. But it seems to me that .results column would just not be very useful?

mjskay commented 4 years ago

How else would people extract variables from the model?