Title
seq_across.Rd
Title
Examples
library(magrittr)
library(dplyr)
bernoulli_trial(prob = .5) %>%
add_trials(3) %>%
.$out %>%
seq_across() %>%
prod_across() %>%
group_by(global_outcome) %>%
summarize(probs = sum(global_probs))
#> # A tibble: 16 × 2
#> global_outcome probs
#> <chr> <dbl>
#> 1 0, 0, 0, 0 0.0625
#> 2 0, 0, 0, 1 0.0625
#> 3 0, 0, 1, 0 0.0625
#> 4 0, 0, 1, 1 0.0625
#> 5 0, 1, 0, 0 0.0625
#> 6 0, 1, 0, 1 0.0625
#> 7 0, 1, 1, 0 0.0625
#> 8 0, 1, 1, 1 0.0625
#> 9 1, 0, 0, 0 0.0625
#> 10 1, 0, 0, 1 0.0625
#> 11 1, 0, 1, 0 0.0625
#> 12 1, 0, 1, 1 0.0625
#> 13 1, 1, 0, 0 0.0625
#> 14 1, 1, 0, 1 0.0625
#> 15 1, 1, 1, 0 0.0625
#> 16 1, 1, 1, 1 0.0625
library(magrittr)
library(dplyr)
bernoulli_trial(prob = .25) %>%
add_trials(3) %>%
.$out %>%
seq_across() %>%
prod_across()
#> # A tibble: 16 × 11
#> global_probs global…¹ history t1_ou…² t1_prob t2_ou…³ t2_prob t3_ou…⁴ t3_prob
#> <dbl> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.316 0, 0, 0… 1 0 0.75 0 0.75 0 0.75
#> 2 0.105 0, 0, 0… 2 0 0.75 0 0.75 0 0.75
#> 3 0.105 0, 0, 1… 3 0 0.75 0 0.75 1 0.25
#> 4 0.0352 0, 0, 1… 4 0 0.75 0 0.75 1 0.25
#> 5 0.105 0, 1, 0… 5 0 0.75 1 0.25 0 0.75
#> 6 0.0352 0, 1, 0… 6 0 0.75 1 0.25 0 0.75
#> 7 0.0352 0, 1, 1… 7 0 0.75 1 0.25 1 0.25
#> 8 0.0117 0, 1, 1… 8 0 0.75 1 0.25 1 0.25
#> 9 0.105 1, 0, 0… 9 1 0.25 0 0.75 0 0.75
#> 10 0.0352 1, 0, 0… 10 1 0.25 0 0.75 0 0.75
#> 11 0.0352 1, 0, 1… 11 1 0.25 0 0.75 1 0.25
#> 12 0.0117 1, 0, 1… 12 1 0.25 0 0.75 1 0.25
#> 13 0.0352 1, 1, 0… 13 1 0.25 1 0.25 0 0.75
#> 14 0.0117 1, 1, 0… 14 1 0.25 1 0.25 0 0.75
#> 15 0.0117 1, 1, 1… 15 1 0.25 1 0.25 1 0.25
#> 16 0.00391 1, 1, 1… 16 1 0.25 1 0.25 1 0.25
#> # … with 2 more variables: t4_outcome <dbl>, t4_prob <dbl>, and abbreviated
#> # variable names ¹global_outcome, ²t1_outcome, ³t2_outcome, ⁴t3_outcome