This method adds one or more branch conditions to
an existing mverse
object. Branch conditions
are used to specify an option in one branch dependent
on an option in another branch.
add_branch_condition(.mverse, ...)
# S3 method for mverse
add_branch_condition(.mverse, ...)
a mverse
object.
branch conditions.
a mverse
object.
Other branch condition functions:
branch_condition()
# Define branches and add them to an \code{mverse} object.
y <- mutate_branch(alldeaths, log(alldeaths + 1))
distribution <- family_branch(poisson, gaussian)
# You can match branching options by providing the options
# the way provide them when defining branches.
match_poisson <- branch_condition(alldeaths, poisson)
mv <- mverse(hurricane) %>%
add_mutate_branch(y) %>%
add_family_branch(distribution) %>%
add_branch_condition(match_poisson)
summary(mv)
#> # A tibble: 3 × 5
#> universe distribution_branch y_branch distribution_branch_code y_branch_code
#> <fct> <fct> <fct> <fct> <fct>
#> 1 1 distribution_1 y_1 poisson alldeaths
#> 2 2 distribution_1 y_2 poisson log(alldeaths …
#> 3 3 distribution_2 y_2 gaussian log(alldeaths …
# You can also condition to reject a pair of options by
# setting reject = TRUE.
match_log_lin <- branch_condition(log(alldeaths + 1), poisson, reject = TRUE)
mv <- add_branch_condition(mv, match_log_lin)
summary(mv)
#> # A tibble: 2 × 5
#> universe distribution_branch y_branch distribution_branch_code y_branch_code
#> <fct> <fct> <fct> <fct> <fct>
#> 1 1 distribution_1 y_1 poisson alldeaths
#> 2 2 distribution_2 y_2 gaussian log(alldeaths …