Title
prod_across.Rd
Title
Examples
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
library(magrittr)
bernoulli_trial(prob = .5) %>%
add_trials() %>%
add_trials() %>%
add_trials(5) %>%
.$out %>%
sum_across() %>%
prod_across() %>%
group_by(global_outcome) %>%
summarize(probs = sum(global_probs))
#> # A tibble: 9 × 2
#> global_outcome probs
#> <dbl> <dbl>
#> 1 0 0.00391
#> 2 1 0.0312
#> 3 2 0.109
#> 4 3 0.219
#> 5 4 0.273
#> 6 5 0.219
#> 7 6 0.109
#> 8 7 0.0312
#> 9 8 0.00391
bernoulli_trial(prob = .5) %>%
add_trials() %>%
add_trials() %>%
add_trials(5) %>%
.$out %>%
sum_across() %>%
prod_across()
#> # A tibble: 256 × 19
#> global_probs global…¹ history t1_ou…² t1_prob t2_ou…³ t2_prob t3_ou…⁴ t3_prob
#> <dbl> <dbl> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.00391 0 1 0 0.5 0 0.5 0 0.5
#> 2 0.00391 1 2 0 0.5 0 0.5 0 0.5
#> 3 0.00391 1 3 0 0.5 0 0.5 0 0.5
#> 4 0.00391 2 4 0 0.5 0 0.5 0 0.5
#> 5 0.00391 1 5 0 0.5 0 0.5 0 0.5
#> 6 0.00391 2 6 0 0.5 0 0.5 0 0.5
#> 7 0.00391 2 7 0 0.5 0 0.5 0 0.5
#> 8 0.00391 3 8 0 0.5 0 0.5 0 0.5
#> 9 0.00391 1 9 0 0.5 0 0.5 0 0.5
#> 10 0.00391 2 10 0 0.5 0 0.5 0 0.5
#> # … with 246 more rows, 10 more variables: t4_outcome <dbl>, t4_prob <dbl>,
#> # t5_outcome <dbl>, t5_prob <dbl>, t6_outcome <dbl>, t6_prob <dbl>,
#> # t7_outcome <dbl>, t7_prob <dbl>, t8_outcome <dbl>, t8_prob <dbl>, and
#> # abbreviated variable names ¹global_outcome, ²t1_outcome, ³t2_outcome,
#> # ⁴t3_outcome