# \donttest{
M.1 <- multiverse()
# using `inside` to declare multiverse code
inside(M.1, {
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
))
})
# declaring multiple options for a data processing step (calculating a new variable)
data(durante)
df <- durante
inside(M.1, {
df <- df %>%
mutate( ComputedCycleLength = StartDateofLastPeriod - StartDateofPeriodBeforeLast ) %>%
mutate( NextMenstrualOnset = branch(menstrual_calculation,
"mc_option1" ~ StartDateofLastPeriod + ComputedCycleLength,
"mc_option2" ~ StartDateofLastPeriod + ReportedCycleLength,
"mc_option3" ~ StartDateNext
))
})
# }
Run the code above in your browser using DataLab