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

Behavior of printing whilst compiling using knitr #121

Closed abhsarma closed 2 months ago

abhsarma commented 3 months ago

From #118

How to support printing whilst compiling using knitr? Multiverse supports two types of code chunks: r and multiverse. How should each of these behave whilst knitting?

printing using an R code chunk

we have the following options:

  1. ~Print the last evaluation (i.e. the output from the last universe at that point in the code, which may not be the last universe in the overall universe)~
  2. Do not allow a user to print variables declared from a multiverse code block using r by throwing an error

printing using a multiverse code chunk:

we have the following options:

  1. ~Print an output for each universe. This can get annoying if one is trying to print a data frame and ends up with hundreds of data frames.~
  2. Do not print anything unless the user is compiling as an emar using the knit_as_emar() function. The knit_as_emar() function will incorporate the necessary tangle widgets which will allow the user to navigate the output of all the universes. If the user is not using knit_as_emar(), simply show the original multiverse code including branch functions but do not evaluate.
mjskay commented 3 months ago

(2) seems reasonable to me when knitting. If you want a single value, either use a {multiverse} block or extract the variable from the specific universe you want and print that in an {r} block... right?