extract_variables | R Documentation |
This is a wrapper function for extracting one or more variables and objects declared from within the multiverse in a tidy format.
extract_variables(x, ..., .results = .results)
## S3 method for class 'multiverse'
extract_variables(x, ..., .results = .results)
## S3 method for class 'data.frame'
extract_variables(x, ..., .results = .results)
x |
either a multiverse object or a dataframe (created using |
... |
one or more variable (or object) names to be extracted from the multiverse object. The names can be quoted or unquoted. |
.results |
(Optional) if the .results column which stores the environments for each unique analysis has been changed,
specify the new name of the column. Defaults to |
In a typical analysis, the user will declare variables and objects inside the multiverse object.
However, it might be difficult to access the variables and objects, hence we provide convenient wrappers
in the form of extract_variables()
.
If the user wants to extract one or more literals (strings, integers, doubles or logicals of length 1) then each variables is separated out into its own column. If the user wants to extract one or more vectors (or lists) then each such variable will be extracted in its own list column. If the user wants to extract one or more dataframe then they a column of type data frame (or tibble) would be created (which is a special instance of a list column).
library(dplyr)
M <- multiverse()
inside(M, {
data <- rnorm(100, 50, 20)
x.mean <- mean(data, trim = branch(
trim_values,
"trim_none" ~ 0,
"trim_1pc" ~ 0.05,
"trim_5pc" ~ 0.025,
"trim_10pc" ~ 0.05
))
y <- sd(data)
})
# Extracts the relevant variable from the multiverse
M %>%
extract_variables(x.mean)
# if you want to filter the multiverse before extracting variables from it
# you ca first create the table and manipulate it before extracting variables
expand(M) %>%
extract_variables(x.mean)
# you can extract more than one variable from the multiverse simultaneously
# these variables will be new columns in the dataset
expand(M) %>%
extract_variables(x.mean, y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.