Skip to contents

An easier way to interact with a multiverse object by using a custom code block

Details

This is a custom code block that allows the users to interface directly with a created multiverse object. This allows users to implement analysis in RMarkdown without using auxiliary functions such as inside(). However, inside() is still required to define and execute multiverse analyses in a RScript using this package. See vignette("multiverse-in-rmd") for more details.

In RStudio, you can create a shortcut for this using RStudio AddIns (we recommend Cmd + Opt + M in Mac and Ctrl + Alt + M in Windows). To add a shortcut, go to Tools > AddIns > Browse AddIns... > Keyboard shortcuts. Search for insert multiverse code chunk and add a keyboard shortcut to this function. Once you have set this up, the keyboard shortcut will create a code block in any RMarkdown document.

Code Block Options

The multiverse code blocks require two named arguments:

  1. label: this is a unique identifier for each code block. If the same label is used for two different code blocks, the code associated with the previous block in the multiverse will be overwritten by the subsequent one. If a code block is created using the keyboard shortcut, it will auto-generate a (unique) label

  2. inside: the multiverse object this code block will be associated with. Defaults to "M"