class: center, middle, inverse, title-slide .title[ # A minimal flipbook ] .subtitle[ ## With flipbookr and xaringan ] .author[ ### You! ] --- ```r # This is the recommended set up for flipbooks # you might think about setting cache to TRUE as you gain practice --- building flipbooks from scratch can be time consuming knitr::opts_chunk$set(fig.width = 6, message = FALSE, warning = FALSE, comment = "", cache = F) library(flipbookr) library(tidyverse) ``` ``` ## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ── ## ✔ dplyr 1.1.0 ✔ readr 2.1.4 ## ✔ forcats 1.0.0 ✔ stringr 1.5.0 ## ✔ ggplot2 3.4.1 ✔ tibble 3.2.0 ## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0 ## ✔ purrr 1.0.1 ## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ── ## ✖ dplyr::filter() masks stats::filter() ## ✖ dplyr::lag() masks stats::lag() ## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors ``` ```r #remotes::install_github("dcl-docs/dcldata") ``` --- class: inverse, middle, center # First up: classic flipbook, using defaults to walk through code pipeline --- count: false .panel1-my_cars-auto[ ```r *ncells <- function(data){nrow(data)*ncol(data)} ``` ] .panel2-my_cars-auto[ ] --- count: false .panel1-my_cars-auto[ ```r ncells <- function(data){nrow(data)*ncol(data)} *dcldata::example_eagle_nests ``` ] .panel2-my_cars-auto[ ``` # A tibble: 3 × 3 region `2007` `2009` <chr> <dbl> <dbl> 1 Pacific 1039 2587 2 Southwest 51 176 3 Rocky Mountains and Plains 200 338 ``` ] --- count: false .panel1-my_cars-auto[ ```r ncells <- function(data){nrow(data)*ncol(data)} dcldata::example_eagle_nests %>% * pivot_longer( * cols = c(`2007`, `2009`), * names_to = "year", * values_to = "num_nests" * ) ``` ] .panel2-my_cars-auto[ ``` # A tibble: 6 × 3 region year num_nests <chr> <chr> <dbl> 1 Pacific 2007 1039 2 Pacific 2009 2587 3 Southwest 2007 51 4 Southwest 2009 176 5 Rocky Mountains and Plains 2007 200 6 Rocky Mountains and Plains 2009 338 ``` ] --- count: false .panel1-my_cars-auto[ ```r ncells <- function(data){nrow(data)*ncol(data)} dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", values_to = "num_nests" ) -> *long; ncells(long) ``` ] .panel2-my_cars-auto[ ``` [1] 18 ``` ] --- count: false .panel1-my_cars-auto[ ```r ncells <- function(data){nrow(data)*ncol(data)} dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", values_to = "num_nests" ) -> long; ncells(long) *long ``` ] .panel2-my_cars-auto[ ``` [1] 18 ``` ``` # A tibble: 6 × 3 region year num_nests <chr> <chr> <dbl> 1 Pacific 2007 1039 2 Pacific 2009 2587 3 Southwest 2007 51 4 Southwest 2009 176 5 Rocky Mountains and Plains 2007 200 6 Rocky Mountains and Plains 2009 338 ``` ] --- count: false .panel1-my_cars-auto[ ```r ncells <- function(data){nrow(data)*ncol(data)} dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", values_to = "num_nests" ) -> long; ncells(long) long %>% * pivot_wider( * names_from = year, * values_from = num_nests * ) ``` ] .panel2-my_cars-auto[ ``` [1] 18 ``` ``` # A tibble: 3 × 3 region `2007` `2009` <chr> <dbl> <dbl> 1 Pacific 1039 2587 2 Southwest 51 176 3 Rocky Mountains and Plains 200 338 ``` ] --- count: false .panel1-my_cars-auto[ ```r ncells <- function(data){nrow(data)*ncol(data)} dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", values_to = "num_nests" ) -> long; ncells(long) long %>% pivot_wider( names_from = year, values_from = num_nests ) -> *back_home_again; ncells(back_home_again) ``` ] .panel2-my_cars-auto[ ``` [1] 18 ``` ``` [1] 9 ``` ] --- count: false .panel1-my_cars-auto[ ```r ncells <- function(data){nrow(data)*ncol(data)} dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", values_to = "num_nests" ) -> long; ncells(long) long %>% pivot_wider( names_from = year, values_from = num_nests ) -> back_home_again; ncells(back_home_again) *dcldata::example_eagle_pairs ``` ] .panel2-my_cars-auto[ ``` [1] 18 ``` ``` [1] 9 ``` ``` # A tibble: 48 × 12 state state…¹ `1997` `1998` `1999` `2000` `2001` `2002` `2003` `2004` `2005` <chr> <chr> <int> <int> <int> <int> <int> <int> <int> <int> <int> 1 Alaba… AL 22 23 26 27 NA NA 47 NA NA 2 Arizo… AZ 34 36 38 37 37 43 43 NA NA 3 Arkan… AR 24 29 34 36 NA NA 36 42 NA 4 Calif… CA 142 148 151 NA NA NA 160 NA 200 5 Color… CO 29 27 29 42 45 NA NA NA 42 6 Conne… CT 2 2 2 4 6 8 8 NA NA 7 Delaw… DE 14 13 14 16 17 26 31 NA NA 8 Flori… FL 874 980 1043 1069 1102 1133 1133 NA 1133 9 Georg… GA 31 37 49 55 61 73 81 NA 82 10 Idaho ID 84 92 95 113 113 128 NA NA NA # … with 38 more rows, 1 more variable: `2006` <int>, and abbreviated variable # name ¹state_abbr ``` ] --- count: false .panel1-my_cars-auto[ ```r ncells <- function(data){nrow(data)*ncol(data)} dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", values_to = "num_nests" ) -> long; ncells(long) long %>% pivot_wider( names_from = year, values_from = num_nests ) -> back_home_again; ncells(back_home_again) dcldata::example_eagle_pairs %>% * pivot_longer( * cols = !starts_with("state"), * names_to = "year", * values_to = "num_pairs" * ) ``` ] .panel2-my_cars-auto[ ``` [1] 18 ``` ``` [1] 9 ``` ``` # A tibble: 480 × 4 state state_abbr year num_pairs <chr> <chr> <chr> <int> 1 Alabama AL 1997 22 2 Alabama AL 1998 23 3 Alabama AL 1999 26 4 Alabama AL 2000 27 5 Alabama AL 2001 NA 6 Alabama AL 2002 NA 7 Alabama AL 2003 47 8 Alabama AL 2004 NA 9 Alabama AL 2005 NA 10 Alabama AL 2006 77 # … with 470 more rows ``` ] --- count: false .panel1-my_cars-auto[ ```r ncells <- function(data){nrow(data)*ncol(data)} dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", values_to = "num_nests" ) -> long; ncells(long) long %>% pivot_wider( names_from = year, values_from = num_nests ) -> back_home_again; ncells(back_home_again) dcldata::example_eagle_pairs %>% pivot_longer( cols = !starts_with("state"), names_to = "year", values_to = "num_pairs" ) -> *also_long; ncells(also_long) ``` ] .panel2-my_cars-auto[ ``` [1] 18 ``` ``` [1] 9 ``` ``` [1] 1920 ``` ] <style> .panel1-my_cars-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-my_cars-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-my_cars-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-my_cars2-auto[ ```r *dcldata::example_acs_1 ``` ] .panel2-my_cars2-auto[ ``` # A tibble: 156 × 4 geoid name variable estimate <chr> <chr> <chr> <dbl> 1 01 Alabama pop_housed 4731852 2 01 Alabama pop_renter 1434765 3 01 Alabama median_rent 747 4 02 Alaska pop_housed 710743 5 02 Alaska pop_renter 241484 6 02 Alaska median_rent 1200 7 04 Arizona pop_housed 6656124 8 04 Arizona pop_renter 2460534 9 04 Arizona median_rent 972 10 05 Arkansas pop_housed 2894098 # … with 146 more rows ``` ] --- count: false .panel1-my_cars2-auto[ ```r dcldata::example_acs_1 %>% * pivot_wider(names_from = variable, * values_from = estimate) ``` ] .panel2-my_cars2-auto[ ``` # A tibble: 52 × 5 geoid name pop_housed pop_renter median_rent <chr> <chr> <dbl> <dbl> <dbl> 1 01 Alabama 4731852 1434765 747 2 02 Alaska 710743 241484 1200 3 04 Arizona 6656124 2460534 972 4 05 Arkansas 2894098 965690 709 5 06 California 38168482 17066023 1358 6 08 Colorado 5318396 1782975 1125 7 09 Connecticut 3478451 1053739 1123 8 10 Delaware 918625 255558 1076 9 11 District of Columbia 632449 354285 1424 10 12 Florida 19847798 7099078 1077 # … with 42 more rows ``` ] --- count: false .panel1-my_cars2-auto[ ```r dcldata::example_acs_1 %>% pivot_wider(names_from = variable, values_from = estimate) -> *df_values_in_columns_like_in_kind ``` ] .panel2-my_cars2-auto[ ] --- count: false .panel1-my_cars2-auto[ ```r dcldata::example_acs_1 %>% pivot_wider(names_from = variable, values_from = estimate) -> df_values_in_columns_like_in_kind *dcldata::example_migration ``` ] .panel2-my_cars2-auto[ ``` # A tibble: 3 × 6 dest Afghanistan Canada India Japan `South Africa` <chr> <chr> <chr> <chr> <chr> <chr> 1 Albania <NA> 913 <NA> <NA> <NA> 2 Bulgaria 483 713 281 213 260 3 Romania <NA> <NA> 102 <NA> <NA> ``` ] --- count: false .panel1-my_cars2-auto[ ```r dcldata::example_acs_1 %>% pivot_wider(names_from = variable, values_from = estimate) -> df_values_in_columns_like_in_kind dcldata::example_migration %>% * pivot_longer(cols = !dest, * names_to = "origin", * values_to = "migrants") ``` ] .panel2-my_cars2-auto[ ``` # A tibble: 15 × 3 dest origin migrants <chr> <chr> <chr> 1 Albania Afghanistan <NA> 2 Albania Canada 913 3 Albania India <NA> 4 Albania Japan <NA> 5 Albania South Africa <NA> 6 Bulgaria Afghanistan 483 7 Bulgaria Canada 713 8 Bulgaria India 281 9 Bulgaria Japan 213 10 Bulgaria South Africa 260 11 Romania Afghanistan <NA> 12 Romania Canada <NA> 13 Romania India 102 14 Romania Japan <NA> 15 Romania South Africa <NA> ``` ] --- count: false .panel1-my_cars2-auto[ ```r dcldata::example_acs_1 %>% pivot_wider(names_from = variable, values_from = estimate) -> df_values_in_columns_like_in_kind dcldata::example_migration %>% pivot_longer(cols = !dest, names_to = "origin", values_to = "migrants") -> *longer_migrans_w_na ``` ] .panel2-my_cars2-auto[ ] --- count: false .panel1-my_cars2-auto[ ```r dcldata::example_acs_1 %>% pivot_wider(names_from = variable, values_from = estimate) -> df_values_in_columns_like_in_kind dcldata::example_migration %>% pivot_longer(cols = !dest, names_to = "origin", values_to = "migrants") -> longer_migrans_w_na *dcldata::example_migration ``` ] .panel2-my_cars2-auto[ ``` # A tibble: 3 × 6 dest Afghanistan Canada India Japan `South Africa` <chr> <chr> <chr> <chr> <chr> <chr> 1 Albania <NA> 913 <NA> <NA> <NA> 2 Bulgaria 483 713 281 213 260 3 Romania <NA> <NA> 102 <NA> <NA> ``` ] --- count: false .panel1-my_cars2-auto[ ```r dcldata::example_acs_1 %>% pivot_wider(names_from = variable, values_from = estimate) -> df_values_in_columns_like_in_kind dcldata::example_migration %>% pivot_longer(cols = !dest, names_to = "origin", values_to = "migrants") -> longer_migrans_w_na dcldata::example_migration %>% * pivot_longer( * cols = !dest, * names_to = "origin", * values_to = "migrants", * values_drop_na = TRUE) ``` ] .panel2-my_cars2-auto[ ``` # A tibble: 7 × 3 dest origin migrants <chr> <chr> <chr> 1 Albania Canada 913 2 Bulgaria Afghanistan 483 3 Bulgaria Canada 713 4 Bulgaria India 281 5 Bulgaria Japan 213 6 Bulgaria South Africa 260 7 Romania India 102 ``` ] --- count: false .panel1-my_cars2-auto[ ```r dcldata::example_acs_1 %>% pivot_wider(names_from = variable, values_from = estimate) -> df_values_in_columns_like_in_kind dcldata::example_migration %>% pivot_longer(cols = !dest, names_to = "origin", values_to = "migrants") -> longer_migrans_w_na dcldata::example_migration %>% pivot_longer( cols = !dest, names_to = "origin", values_to = "migrants", values_drop_na = TRUE) -> *longer_migrans_wo_na ``` ] .panel2-my_cars2-auto[ ] <style> .panel1-my_cars2-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-my_cars2-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-my_cars2-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-my_cars3-auto[ ```r *dcldata::example_eagle_nests ``` ] .panel2-my_cars3-auto[ ``` # A tibble: 3 × 3 region `2007` `2009` <chr> <dbl> <dbl> 1 Pacific 1039 2587 2 Southwest 51 176 3 Rocky Mountains and Plains 200 338 ``` ] --- count: false .panel1-my_cars3-auto[ ```r dcldata::example_eagle_nests %>% * pivot_longer( * cols = c(`2007`, `2009`), * names_to = "year", * names_transform = list(year = as.integer), * values_to = "num_nests" * ) ``` ] .panel2-my_cars3-auto[ ``` # A tibble: 6 × 3 region year num_nests <chr> <int> <dbl> 1 Pacific 2007 1039 2 Pacific 2009 2587 3 Southwest 2007 51 4 Southwest 2009 176 5 Rocky Mountains and Plains 2007 200 6 Rocky Mountains and Plains 2009 338 ``` ] --- count: false .panel1-my_cars3-auto[ ```r dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", names_transform = list(year = as.integer), values_to = "num_nests" ) -> *long_nests_col_names_to_int ``` ] .panel2-my_cars3-auto[ ] --- count: false .panel1-my_cars3-auto[ ```r dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", names_transform = list(year = as.integer), values_to = "num_nests" ) -> long_nests_col_names_to_int *dcldata::example_eagle_nests ``` ] .panel2-my_cars3-auto[ ``` # A tibble: 3 × 3 region `2007` `2009` <chr> <dbl> <dbl> 1 Pacific 1039 2587 2 Southwest 51 176 3 Rocky Mountains and Plains 200 338 ``` ] --- count: false .panel1-my_cars3-auto[ ```r dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", names_transform = list(year = as.integer), values_to = "num_nests" ) -> long_nests_col_names_to_int dcldata::example_eagle_nests %>% * pivot_longer( * cols = c(`2007`, `2009`), * names_to = "year", * names_transform = list(year = as.integer), * values_to = "num_nests", * values_transform = list(num_nests = as.integer) * ) ``` ] .panel2-my_cars3-auto[ ``` # A tibble: 6 × 3 region year num_nests <chr> <int> <int> 1 Pacific 2007 1039 2 Pacific 2009 2587 3 Southwest 2007 51 4 Southwest 2009 176 5 Rocky Mountains and Plains 2007 200 6 Rocky Mountains and Plains 2009 338 ``` ] --- count: false .panel1-my_cars3-auto[ ```r dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", names_transform = list(year = as.integer), values_to = "num_nests" ) -> long_nests_col_names_to_int dcldata::example_eagle_nests %>% pivot_longer( cols = c(`2007`, `2009`), names_to = "year", names_transform = list(year = as.integer), values_to = "num_nests", values_transform = list(num_nests = as.integer) ) -> *long_nest_valus_num_to_int ``` ] .panel2-my_cars3-auto[ ] <style> .panel1-my_cars3-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-my_cars3-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-my_cars3-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-my_cars4-auto[ ```r *dcldata::example_gymnastics_1 ``` ] .panel2-my_cars4-auto[ ``` # A tibble: 3 × 3 country score_vault score_floor <chr> <dbl> <dbl> 1 United States 46.9 46.0 2 Russia 45.7 42.0 3 China 44.3 42.1 ``` ] --- count: false .panel1-my_cars4-auto[ ```r dcldata::example_gymnastics_1 %>% * pivot_longer( * cols = !country, * names_to = "event", * values_to = "score" * ) ``` ] .panel2-my_cars4-auto[ ``` # A tibble: 6 × 3 country event score <chr> <chr> <dbl> 1 United States score_vault 46.9 2 United States score_floor 46.0 3 Russia score_vault 45.7 4 Russia score_floor 42.0 5 China score_vault 44.3 6 China score_floor 42.1 ``` ] --- count: false .panel1-my_cars4-auto[ ```r dcldata::example_gymnastics_1 %>% pivot_longer( cols = !country, names_to = "event", values_to = "score" ) -> *okay ``` ] .panel2-my_cars4-auto[ ] --- count: false .panel1-my_cars4-auto[ ```r dcldata::example_gymnastics_1 %>% pivot_longer( cols = !country, names_to = "event", values_to = "score" ) -> okay *dcldata::example_gymnastics_1 ``` ] .panel2-my_cars4-auto[ ``` # A tibble: 3 × 3 country score_vault score_floor <chr> <dbl> <dbl> 1 United States 46.9 46.0 2 Russia 45.7 42.0 3 China 44.3 42.1 ``` ] --- count: false .panel1-my_cars4-auto[ ```r dcldata::example_gymnastics_1 %>% pivot_longer( cols = !country, names_to = "event", values_to = "score" ) -> okay dcldata::example_gymnastics_1 %>% * pivot_longer( * cols = !country, * names_to = "event", * names_prefix = "score_", * values_to = "score" * ) ``` ] .panel2-my_cars4-auto[ ``` # A tibble: 6 × 3 country event score <chr> <chr> <dbl> 1 United States vault 46.9 2 United States floor 46.0 3 Russia vault 45.7 4 Russia floor 42.0 5 China vault 44.3 6 China floor 42.1 ``` ] --- count: false .panel1-my_cars4-auto[ ```r dcldata::example_gymnastics_1 %>% pivot_longer( cols = !country, names_to = "event", values_to = "score" ) -> okay dcldata::example_gymnastics_1 %>% pivot_longer( cols = !country, names_to = "event", names_prefix = "score_", values_to = "score" ) -> *okay_prefix ``` ] .panel2-my_cars4-auto[ ] <style> .panel1-my_cars4-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-my_cars4-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-my_cars4-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-my_cars5-auto[ ```r *dcldata::example_gymnastics_2 ``` ] .panel2-my_cars5-auto[ ``` # A tibble: 3 × 5 country vault_2012 floor_2012 vault_2016 floor_2016 <chr> <dbl> <dbl> <dbl> <dbl> 1 United States 48.1 45.4 46.9 46.0 2 Russia 46.4 41.6 45.7 42.0 3 China 44.3 40.8 44.3 42.1 ``` ] --- count: false .panel1-my_cars5-auto[ ```r dcldata::example_gymnastics_2 %>% * pivot_longer( * cols = !country, * names_to = "event_year", * values_to = "score" * ) ``` ] .panel2-my_cars5-auto[ ``` # A tibble: 12 × 3 country event_year score <chr> <chr> <dbl> 1 United States vault_2012 48.1 2 United States floor_2012 45.4 3 United States vault_2016 46.9 4 United States floor_2016 46.0 5 Russia vault_2012 46.4 6 Russia floor_2012 41.6 7 Russia vault_2016 45.7 8 Russia floor_2016 42.0 9 China vault_2012 44.3 10 China floor_2012 40.8 11 China vault_2016 44.3 12 China floor_2016 42.1 ``` ] --- count: false .panel1-my_cars5-auto[ ```r dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = "event_year", values_to = "score" ) -> *gym_partial ``` ] .panel2-my_cars5-auto[ ] --- count: false .panel1-my_cars5-auto[ ```r dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = "event_year", values_to = "score" ) -> gym_partial *dcldata::example_gymnastics_2 ``` ] .panel2-my_cars5-auto[ ``` # A tibble: 3 × 5 country vault_2012 floor_2012 vault_2016 floor_2016 <chr> <dbl> <dbl> <dbl> <dbl> 1 United States 48.1 45.4 46.9 46.0 2 Russia 46.4 41.6 45.7 42.0 3 China 44.3 40.8 44.3 42.1 ``` ] --- count: false .panel1-my_cars5-auto[ ```r dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = "event_year", values_to = "score" ) -> gym_partial dcldata::example_gymnastics_2 %>% * pivot_longer( * cols = !country, * names_to = c("event", "year"), * names_sep = "_", * values_to = "score" * ) ``` ] .panel2-my_cars5-auto[ ``` # A tibble: 12 × 4 country event year score <chr> <chr> <chr> <dbl> 1 United States vault 2012 48.1 2 United States floor 2012 45.4 3 United States vault 2016 46.9 4 United States floor 2016 46.0 5 Russia vault 2012 46.4 6 Russia floor 2012 41.6 7 Russia vault 2016 45.7 8 Russia floor 2016 42.0 9 China vault 2012 44.3 10 China floor 2012 40.8 11 China vault 2016 44.3 12 China floor 2016 42.1 ``` ] --- count: false .panel1-my_cars5-auto[ ```r dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = "event_year", values_to = "score" ) -> gym_partial dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = c("event", "year"), names_sep = "_", values_to = "score" ) -> *gym_two ``` ] .panel2-my_cars5-auto[ ] --- count: false .panel1-my_cars5-auto[ ```r dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = "event_year", values_to = "score" ) -> gym_partial dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = c("event", "year"), names_sep = "_", values_to = "score" ) -> gym_two *dcldata::example_gymnastics_3 ``` ] .panel2-my_cars5-auto[ ``` # A tibble: 3 × 9 country vault_…¹ vault…² vault…³ vault…⁴ floor…⁵ floor…⁶ floor…⁷ floor…⁸ <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> 1 United States 48.1 46.6 46.9 45.9 45.4 45.3 46.0 43.8 2 Russia 46.4 46.9 45.7 46.0 41.6 45.3 42.0 44.8 3 China 44.3 48.3 44.3 45 40.8 45.1 42.1 43.8 # … with abbreviated variable names ¹vault_2012_f, ²vault_2012_m, # ³vault_2016_f, ⁴vault_2016_m, ⁵floor_2012_f, ⁶floor_2012_m, ⁷floor_2016_f, # ⁸floor_2016_m ``` ] --- count: false .panel1-my_cars5-auto[ ```r dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = "event_year", values_to = "score" ) -> gym_partial dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = c("event", "year"), names_sep = "_", values_to = "score" ) -> gym_two dcldata::example_gymnastics_3 %>% * pivot_longer( * cols = !country, * names_to = c("event", "year", "gender"), * names_sep = "_", * values_to = "score" * ) ``` ] .panel2-my_cars5-auto[ ``` # A tibble: 24 × 5 country event year gender score <chr> <chr> <chr> <chr> <dbl> 1 United States vault 2012 f 48.1 2 United States vault 2012 m 46.6 3 United States vault 2016 f 46.9 4 United States vault 2016 m 45.9 5 United States floor 2012 f 45.4 6 United States floor 2012 m 45.3 7 United States floor 2016 f 46.0 8 United States floor 2016 m 43.8 9 Russia vault 2012 f 46.4 10 Russia vault 2012 m 46.9 # … with 14 more rows ``` ] --- count: false .panel1-my_cars5-auto[ ```r dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = "event_year", values_to = "score" ) -> gym_partial dcldata::example_gymnastics_2 %>% pivot_longer( cols = !country, names_to = c("event", "year"), names_sep = "_", values_to = "score" ) -> gym_two dcldata::example_gymnastics_3 %>% pivot_longer( cols = !country, names_to = c("event", "year", "gender"), names_sep = "_", values_to = "score" ) -> *gym_three ``` ] .panel2-my_cars5-auto[ ] <style> .panel1-my_cars5-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-my_cars5-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-my_cars5-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> <!-- adjust font size in this css code chunk, currently 80 --> --- count: false .panel1-my_cars6-auto[ ```r *library(tidybernoulli) ``` ] .panel2-my_cars6-auto[ ] --- count: false .panel1-my_cars6-auto[ ```r library(tidybernoulli) *library(tidyverse) ``` ] .panel2-my_cars6-auto[ ] --- count: false .panel1-my_cars6-auto[ ```r library(tidybernoulli) library(tidyverse) *bernoulli_trial() ``` ] .panel2-my_cars6-auto[ ``` outcome prob 1 0 0.75 2 1 0.25 ``` ] --- count: false .panel1-my_cars6-auto[ ```r library(tidybernoulli) library(tidyverse) bernoulli_trial() %>% * trial_init() ``` ] .panel2-my_cars6-auto[ ``` history t1_outcome t1_prob 1 1 0 0.75 2 2 1 0.25 ``` ] --- count: false .panel1-my_cars6-auto[ ```r library(tidybernoulli) library(tidyverse) bernoulli_trial() %>% trial_init() %>% * trial_advance(2) ``` ] .panel2-my_cars6-auto[ ``` # A tibble: 8 × 7 history t1_outcome t1_prob t2_outcome t2_prob t3_outcome t3_prob <int> <int> <dbl> <int> <dbl> <int> <dbl> 1 1 0 0.75 0 0.75 0 0.75 2 2 0 0.75 0 0.75 1 0.25 3 3 0 0.75 1 0.25 0 0.75 4 4 0 0.75 1 0.25 1 0.25 5 5 1 0.25 0 0.75 0 0.75 6 6 1 0.25 0 0.75 1 0.25 7 7 1 0.25 1 0.25 0 0.75 8 8 1 0.25 1 0.25 1 0.25 ``` ] --- count: false .panel1-my_cars6-auto[ ```r library(tidybernoulli) library(tidyverse) bernoulli_trial() %>% trial_init() %>% trial_advance(2) %>% * .$out ``` ] .panel2-my_cars6-auto[ ``` # A tibble: 8 × 7 history t1_outcome t1_prob t2_outcome t2_prob t3_outcome t3_prob <int> <int> <dbl> <int> <dbl> <int> <dbl> 1 1 0 0.75 0 0.75 0 0.75 2 2 0 0.75 0 0.75 1 0.25 3 3 0 0.75 1 0.25 0 0.75 4 4 0 0.75 1 0.25 1 0.25 5 5 1 0.25 0 0.75 0 0.75 6 6 1 0.25 0 0.75 1 0.25 7 7 1 0.25 1 0.25 0 0.75 8 8 1 0.25 1 0.25 1 0.25 ``` ] --- count: false .panel1-my_cars6-auto[ ```r library(tidybernoulli) library(tidyverse) bernoulli_trial() %>% trial_init() %>% trial_advance(2) %>% .$out %>% * pivot_longer(cols = -history, names_sep = "_", * names_to = c("trial","name")) ``` ] .panel2-my_cars6-auto[ ``` # A tibble: 48 × 4 history trial name value <int> <chr> <chr> <dbl> 1 1 t1 outcome 0 2 1 t1 prob 0.75 3 1 t2 outcome 0 4 1 t2 prob 0.75 5 1 t3 outcome 0 6 1 t3 prob 0.75 7 2 t1 outcome 0 8 2 t1 prob 0.75 9 2 t2 outcome 0 10 2 t2 prob 0.75 # … with 38 more rows ``` ] --- count: false .panel1-my_cars6-auto[ ```r library(tidybernoulli) library(tidyverse) bernoulli_trial() %>% trial_init() %>% trial_advance(2) %>% .$out %>% pivot_longer(cols = -history, names_sep = "_", names_to = c("trial","name")) %>% * pivot_wider(names_from = name, values_from = value) ``` ] .panel2-my_cars6-auto[ ``` # A tibble: 24 × 4 history trial outcome prob <int> <chr> <dbl> <dbl> 1 1 t1 0 0.75 2 1 t2 0 0.75 3 1 t3 0 0.75 4 2 t1 0 0.75 5 2 t2 0 0.75 6 2 t3 1 0.25 7 3 t1 0 0.75 8 3 t2 1 0.25 9 3 t3 0 0.75 10 4 t1 0 0.75 # … with 14 more rows ``` ] --- count: false .panel1-my_cars6-auto[ ```r library(tidybernoulli) library(tidyverse) bernoulli_trial() %>% trial_init() %>% trial_advance(2) %>% .$out %>% pivot_longer(cols = -history, names_sep = "_", names_to = c("trial","name")) %>% pivot_wider(names_from = name, values_from = value) ``` ] .panel2-my_cars6-auto[ ``` # A tibble: 24 × 4 history trial outcome prob <int> <chr> <dbl> <dbl> 1 1 t1 0 0.75 2 1 t2 0 0.75 3 1 t3 0 0.75 4 2 t1 0 0.75 5 2 t2 0 0.75 6 2 t3 1 0.25 7 3 t1 0 0.75 8 3 t2 1 0.25 9 3 t3 0 0.75 10 4 t1 0 0.75 # … with 14 more rows ``` ] <style> .panel1-my_cars6-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-my_cars6-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-my_cars6-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-anscombe-auto[ ```r *anscombe ``` ] .panel2-anscombe-auto[ ``` x1 x2 x3 x4 y1 y2 y3 y4 1 10 10 10 8 8.04 9.14 7.46 6.58 2 8 8 8 8 6.95 8.14 6.77 5.76 3 13 13 13 8 7.58 8.74 12.74 7.71 4 9 9 9 8 8.81 8.77 7.11 8.84 5 11 11 11 8 8.33 9.26 7.81 8.47 6 14 14 14 8 9.96 8.10 8.84 7.04 7 6 6 6 8 7.24 6.13 6.08 5.25 8 4 4 4 19 4.26 3.10 5.39 12.50 9 12 12 12 8 10.84 9.13 8.15 5.56 10 7 7 7 8 4.82 7.26 6.42 7.91 11 5 5 5 8 5.68 4.74 5.73 6.89 ``` ] --- count: false .panel1-anscombe-auto[ ```r anscombe %>% * pivot_longer( * everything(), * cols_vary = "slowest", * names_to = c(".value", "set"), * names_pattern = "(.)(.)" * ) ``` ] .panel2-anscombe-auto[ ``` # A tibble: 44 × 3 set x y <chr> <dbl> <dbl> 1 1 10 8.04 2 1 8 6.95 3 1 13 7.58 4 1 9 8.81 5 1 11 8.33 6 1 14 9.96 7 1 6 7.24 8 1 4 4.26 9 1 12 10.8 10 1 7 4.82 # … with 34 more rows ``` ] --- count: false .panel1-anscombe-auto[ ```r anscombe %>% pivot_longer( everything(), cols_vary = "slowest", names_to = c(".value", "set"), names_pattern = "(.)(.)" ) -> *anscombe_mod ``` ] .panel2-anscombe-auto[ ] --- count: false .panel1-anscombe-auto[ ```r anscombe %>% pivot_longer( everything(), cols_vary = "slowest", names_to = c(".value", "set"), names_pattern = "(.)(.)" ) -> anscombe_mod *billboard ``` ] .panel2-anscombe-auto[ ``` # A tibble: 317 × 79 artist track date.ent…¹ wk1 wk2 wk3 wk4 wk5 wk6 wk7 wk8 wk9 <chr> <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> 1 2 Pac Baby… 2000-02-26 87 82 72 77 87 94 99 NA NA 2 2Ge+h… The … 2000-09-02 91 87 92 NA NA NA NA NA NA 3 3 Doo… Kryp… 2000-04-08 81 70 68 67 66 57 54 53 51 4 3 Doo… Loser 2000-10-21 76 76 72 69 67 65 55 59 62 5 504 B… Wobb… 2000-04-15 57 34 25 17 17 31 36 49 53 6 98^0 Give… 2000-08-19 51 39 34 26 26 19 2 2 3 7 A*Tee… Danc… 2000-07-08 97 97 96 95 100 NA NA NA NA 8 Aaliy… I Do… 2000-01-29 84 62 51 41 38 35 35 38 38 9 Aaliy… Try … 2000-03-18 59 53 38 28 21 18 16 14 12 10 Adams… Open… 2000-08-26 76 76 74 69 68 67 61 58 57 # … with 307 more rows, 67 more variables: wk10 <dbl>, wk11 <dbl>, wk12 <dbl>, # wk13 <dbl>, wk14 <dbl>, wk15 <dbl>, wk16 <dbl>, wk17 <dbl>, wk18 <dbl>, # wk19 <dbl>, wk20 <dbl>, wk21 <dbl>, wk22 <dbl>, wk23 <dbl>, wk24 <dbl>, # wk25 <dbl>, wk26 <dbl>, wk27 <dbl>, wk28 <dbl>, wk29 <dbl>, wk30 <dbl>, # wk31 <dbl>, wk32 <dbl>, wk33 <dbl>, wk34 <dbl>, wk35 <dbl>, wk36 <dbl>, # wk37 <dbl>, wk38 <dbl>, wk39 <dbl>, wk40 <dbl>, wk41 <dbl>, wk42 <dbl>, # wk43 <dbl>, wk44 <dbl>, wk45 <dbl>, wk46 <dbl>, wk47 <dbl>, wk48 <dbl>, … ``` ] --- count: false .panel1-anscombe-auto[ ```r anscombe %>% pivot_longer( everything(), cols_vary = "slowest", names_to = c(".value", "set"), names_pattern = "(.)(.)" ) -> anscombe_mod billboard %>% * pivot_longer( * cols = starts_with("wk"), * names_to = "week", * names_prefix = "wk", * values_to = "rank", * values_drop_na = TRUE * ) ``` ] .panel2-anscombe-auto[ ``` # A tibble: 5,307 × 5 artist track date.entered week rank <chr> <chr> <date> <chr> <dbl> 1 2 Pac Baby Don't Cry (Keep... 2000-02-26 1 87 2 2 Pac Baby Don't Cry (Keep... 2000-02-26 2 82 3 2 Pac Baby Don't Cry (Keep... 2000-02-26 3 72 4 2 Pac Baby Don't Cry (Keep... 2000-02-26 4 77 5 2 Pac Baby Don't Cry (Keep... 2000-02-26 5 87 6 2 Pac Baby Don't Cry (Keep... 2000-02-26 6 94 7 2 Pac Baby Don't Cry (Keep... 2000-02-26 7 99 8 2Ge+her The Hardest Part Of ... 2000-09-02 1 91 9 2Ge+her The Hardest Part Of ... 2000-09-02 2 87 10 2Ge+her The Hardest Part Of ... 2000-09-02 3 92 # … with 5,297 more rows ``` ] --- count: false .panel1-anscombe-auto[ ```r anscombe %>% pivot_longer( everything(), cols_vary = "slowest", names_to = c(".value", "set"), names_pattern = "(.)(.)" ) -> anscombe_mod billboard %>% pivot_longer( cols = starts_with("wk"), names_to = "week", names_prefix = "wk", values_to = "rank", values_drop_na = TRUE ) -> *billboard_mod ``` ] .panel2-anscombe-auto[ ] --- count: false .panel1-anscombe-auto[ ```r anscombe %>% pivot_longer( everything(), cols_vary = "slowest", names_to = c(".value", "set"), names_pattern = "(.)(.)" ) -> anscombe_mod billboard %>% pivot_longer( cols = starts_with("wk"), names_to = "week", names_prefix = "wk", values_to = "rank", values_drop_na = TRUE ) -> billboard_mod *who ``` ] .panel2-anscombe-auto[ ``` # A tibble: 7,240 × 60 country iso2 iso3 year new_s…¹ new_s…² new_s…³ new_s…⁴ new_s…⁵ new_s…⁶ <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> 1 Afghanistan AF AFG 1980 NA NA NA NA NA NA 2 Afghanistan AF AFG 1981 NA NA NA NA NA NA 3 Afghanistan AF AFG 1982 NA NA NA NA NA NA 4 Afghanistan AF AFG 1983 NA NA NA NA NA NA 5 Afghanistan AF AFG 1984 NA NA NA NA NA NA 6 Afghanistan AF AFG 1985 NA NA NA NA NA NA 7 Afghanistan AF AFG 1986 NA NA NA NA NA NA 8 Afghanistan AF AFG 1987 NA NA NA NA NA NA 9 Afghanistan AF AFG 1988 NA NA NA NA NA NA 10 Afghanistan AF AFG 1989 NA NA NA NA NA NA # … with 7,230 more rows, 50 more variables: new_sp_m65 <dbl>, # new_sp_f014 <dbl>, new_sp_f1524 <dbl>, new_sp_f2534 <dbl>, # new_sp_f3544 <dbl>, new_sp_f4554 <dbl>, new_sp_f5564 <dbl>, # new_sp_f65 <dbl>, new_sn_m014 <dbl>, new_sn_m1524 <dbl>, # new_sn_m2534 <dbl>, new_sn_m3544 <dbl>, new_sn_m4554 <dbl>, # new_sn_m5564 <dbl>, new_sn_m65 <dbl>, new_sn_f014 <dbl>, # new_sn_f1524 <dbl>, new_sn_f2534 <dbl>, new_sn_f3544 <dbl>, … ``` ] --- count: false .panel1-anscombe-auto[ ```r anscombe %>% pivot_longer( everything(), cols_vary = "slowest", names_to = c(".value", "set"), names_pattern = "(.)(.)" ) -> anscombe_mod billboard %>% pivot_longer( cols = starts_with("wk"), names_to = "week", names_prefix = "wk", values_to = "rank", values_drop_na = TRUE ) -> billboard_mod who %>% * pivot_longer( * cols = new_sp_m014:newrel_f65, * names_to = c("diagnosis", "gender", "age"), * names_pattern = "new_?(.*)_(.)(.*)", * values_to = "count" *) ``` ] .panel2-anscombe-auto[ ``` # A tibble: 405,440 × 8 country iso2 iso3 year diagnosis gender age count <chr> <chr> <chr> <dbl> <chr> <chr> <chr> <dbl> 1 Afghanistan AF AFG 1980 sp m 014 NA 2 Afghanistan AF AFG 1980 sp m 1524 NA 3 Afghanistan AF AFG 1980 sp m 2534 NA 4 Afghanistan AF AFG 1980 sp m 3544 NA 5 Afghanistan AF AFG 1980 sp m 4554 NA 6 Afghanistan AF AFG 1980 sp m 5564 NA 7 Afghanistan AF AFG 1980 sp m 65 NA 8 Afghanistan AF AFG 1980 sp f 014 NA 9 Afghanistan AF AFG 1980 sp f 1524 NA 10 Afghanistan AF AFG 1980 sp f 2534 NA # … with 405,430 more rows ``` ] --- count: false .panel1-anscombe-auto[ ```r anscombe %>% pivot_longer( everything(), cols_vary = "slowest", names_to = c(".value", "set"), names_pattern = "(.)(.)" ) -> anscombe_mod billboard %>% pivot_longer( cols = starts_with("wk"), names_to = "week", names_prefix = "wk", values_to = "rank", values_drop_na = TRUE ) -> billboard_mod who %>% pivot_longer( cols = new_sp_m014:newrel_f65, names_to = c("diagnosis", "gender", "age"), names_pattern = "new_?(.*)_(.)(.*)", values_to = "count" ) -> *who_mod ``` ] .panel2-anscombe-auto[ ] --- count: false .panel1-anscombe-auto[ ```r anscombe %>% pivot_longer( everything(), cols_vary = "slowest", names_to = c(".value", "set"), names_pattern = "(.)(.)" ) -> anscombe_mod billboard %>% pivot_longer( cols = starts_with("wk"), names_to = "week", names_prefix = "wk", values_to = "rank", values_drop_na = TRUE ) -> billboard_mod who %>% pivot_longer( cols = new_sp_m014:newrel_f65, names_to = c("diagnosis", "gender", "age"), names_pattern = "new_?(.*)_(.)(.*)", values_to = "count" ) -> who_mod ``` ] .panel2-anscombe-auto[ ] <style> .panel1-anscombe-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-anscombe-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-anscombe-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-tsibble-auto[ ```r *bernoulli_trial(prob = .5) ``` ] .panel2-tsibble-auto[ ``` outcome prob 1 0 0.5 2 1 0.5 ``` ] --- count: false .panel1-tsibble-auto[ ```r bernoulli_trial(prob = .5) %>% * add_trials() ``` ] .panel2-tsibble-auto[ ``` # A tibble: 4 × 5 history t1_outcome t1_prob t2_outcome t2_prob <int> <int> <dbl> <int> <dbl> 1 1 0 0.5 0 0.5 2 2 0 0.5 1 0.5 3 3 1 0.5 0 0.5 4 4 1 0.5 1 0.5 ``` ] --- count: false .panel1-tsibble-auto[ ```r bernoulli_trial(prob = .5) %>% add_trials() %>% * add_trials() ``` ] .panel2-tsibble-auto[ ``` # A tibble: 8 × 7 history t1_outcome t1_prob t2_outcome t2_prob t3_outcome t3_prob <int> <int> <dbl> <int> <dbl> <int> <dbl> 1 1 0 0.5 0 0.5 0 0.5 2 2 0 0.5 0 0.5 1 0.5 3 3 0 0.5 1 0.5 0 0.5 4 4 0 0.5 1 0.5 1 0.5 5 5 1 0.5 0 0.5 0 0.5 6 6 1 0.5 0 0.5 1 0.5 7 7 1 0.5 1 0.5 0 0.5 8 8 1 0.5 1 0.5 1 0.5 ``` ] --- count: false .panel1-tsibble-auto[ ```r bernoulli_trial(prob = .5) %>% add_trials() %>% add_trials() %>% * to_tsibble() ``` ] .panel2-tsibble-auto[ ``` # A tibble: 24 × 4 history trial outcome prob <int> <chr> <dbl> <dbl> 1 1 t1 0 0.5 2 1 t2 0 0.5 3 1 t3 0 0.5 4 2 t1 0 0.5 5 2 t2 0 0.5 6 2 t3 1 0.5 7 3 t1 0 0.5 8 3 t2 1 0.5 9 3 t3 0 0.5 10 4 t1 0 0.5 # … with 14 more rows ``` ] --- count: false .panel1-tsibble-auto[ ```r bernoulli_trial(prob = .5) %>% add_trials() %>% add_trials() %>% to_tsibble() %>% * group_by(history) ``` ] .panel2-tsibble-auto[ ``` # A tibble: 24 × 4 # Groups: history [8] history trial outcome prob <int> <chr> <dbl> <dbl> 1 1 t1 0 0.5 2 1 t2 0 0.5 3 1 t3 0 0.5 4 2 t1 0 0.5 5 2 t2 0 0.5 6 2 t3 1 0.5 7 3 t1 0 0.5 8 3 t2 1 0.5 9 3 t3 0 0.5 10 4 t1 0 0.5 # … with 14 more rows ``` ] --- count: false .panel1-tsibble-auto[ ```r bernoulli_trial(prob = .5) %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% * summarize(hist_prob = prod(prob), * count_successes = sum(outcome), * paths = paste(outcome, collapse = ",")) ``` ] .panel2-tsibble-auto[ ``` # A tibble: 8 × 4 history hist_prob count_successes paths <int> <dbl> <dbl> <chr> 1 1 0.125 0 0,0,0 2 2 0.125 1 0,0,1 3 3 0.125 1 0,1,0 4 4 0.125 2 0,1,1 5 5 0.125 1 1,0,0 6 6 0.125 2 1,0,1 7 7 0.125 2 1,1,0 8 8 0.125 3 1,1,1 ``` ] --- count: false .panel1-tsibble-auto[ ```r bernoulli_trial(prob = .5) %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% summarize(hist_prob = prod(prob), count_successes = sum(outcome), paths = paste(outcome, collapse = ",")) %>% * arrange(count_successes) ``` ] .panel2-tsibble-auto[ ``` # A tibble: 8 × 4 history hist_prob count_successes paths <int> <dbl> <dbl> <chr> 1 1 0.125 0 0,0,0 2 2 0.125 1 0,0,1 3 3 0.125 1 0,1,0 4 5 0.125 1 1,0,0 5 4 0.125 2 0,1,1 6 6 0.125 2 1,0,1 7 7 0.125 2 1,1,0 8 8 0.125 3 1,1,1 ``` ] --- count: false .panel1-tsibble-auto[ ```r bernoulli_trial(prob = .5) %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% summarize(hist_prob = prod(prob), count_successes = sum(outcome), paths = paste(outcome, collapse = ",")) %>% arrange(count_successes) %>% * group_by(count_successes) ``` ] .panel2-tsibble-auto[ ``` # A tibble: 8 × 4 # Groups: count_successes [4] history hist_prob count_successes paths <int> <dbl> <dbl> <chr> 1 1 0.125 0 0,0,0 2 2 0.125 1 0,0,1 3 3 0.125 1 0,1,0 4 5 0.125 1 1,0,0 5 4 0.125 2 0,1,1 6 6 0.125 2 1,0,1 7 7 0.125 2 1,1,0 8 8 0.125 3 1,1,1 ``` ] --- count: false .panel1-tsibble-auto[ ```r bernoulli_trial(prob = .5) %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% summarize(hist_prob = prod(prob), count_successes = sum(outcome), paths = paste(outcome, collapse = ",")) %>% arrange(count_successes) %>% group_by(count_successes) %>% * summarize(count_prob = sum(hist_prob)) ``` ] .panel2-tsibble-auto[ ``` # A tibble: 4 × 2 count_successes count_prob <dbl> <dbl> 1 0 0.125 2 1 0.375 3 2 0.375 4 3 0.125 ``` ] --- count: false .panel1-tsibble-auto[ ```r bernoulli_trial(prob = .5) %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% summarize(hist_prob = prod(prob), count_successes = sum(outcome), paths = paste(outcome, collapse = ",")) %>% arrange(count_successes) %>% group_by(count_successes) %>% summarize(count_prob = sum(hist_prob)) ``` ] .panel2-tsibble-auto[ ``` # A tibble: 4 × 2 count_successes count_prob <dbl> <dbl> 1 0 0.125 2 1 0.375 3 2 0.375 4 3 0.125 ``` ] <style> .panel1-tsibble-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-tsibble-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-tsibble-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-veridicalp-auto[ ```r *options(pillar.print_max = Inf) ``` ] .panel2-veridicalp-auto[ ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) *fair_coin(outcome_set = c("T", "H")) ``` ] .panel2-veridicalp-auto[ ``` outcome prob 1 T 0.5 2 H 0.5 ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% * select(-prob) ``` ] .panel2-veridicalp-auto[ ``` outcome 1 T 2 H ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% * trial_init() ``` ] .panel2-veridicalp-auto[ ``` history t1_outcome 1 1 T 2 2 H ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% * add_trials() ``` ] .panel2-veridicalp-auto[ ``` # A tibble: 4 × 3 history t1_outcome t2_outcome <int> <chr> <chr> 1 1 H H 2 2 H T 3 3 T H 4 4 T T ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% * add_trials() ``` ] .panel2-veridicalp-auto[ ``` # A tibble: 8 × 4 history t1_outcome t2_outcome t3_outcome <int> <chr> <chr> <chr> 1 1 H H H 2 2 H H T 3 3 H T H 4 4 H T T 5 5 T H H 6 6 T H T 7 7 T T H 8 8 T T T ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% * add_trials() ``` ] .panel2-veridicalp-auto[ ``` # A tibble: 16 × 5 history t1_outcome t2_outcome t3_outcome t4_outcome <int> <chr> <chr> <chr> <chr> 1 1 H H H H 2 2 H H H T 3 3 H H T H 4 4 H H T T 5 5 H T H H 6 6 H T H T 7 7 H T T H 8 8 H T T T 9 9 T H H H 10 10 T H H T 11 11 T H T H 12 12 T H T T 13 13 T T H H 14 14 T T H T 15 15 T T T H 16 16 T T T T ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% * add_trials() ``` ] .panel2-veridicalp-auto[ ``` # A tibble: 32 × 6 history t1_outcome t2_outcome t3_outcome t4_outcome t5_outcome <int> <chr> <chr> <chr> <chr> <chr> 1 1 H H H H H 2 2 H H H H T 3 3 H H H T H 4 4 H H H T T 5 5 H H T H H 6 6 H H T H T 7 7 H H T T H 8 8 H H T T T 9 9 H T H H H 10 10 H T H H T 11 11 H T H T H 12 12 H T H T T 13 13 H T T H H 14 14 H T T H T 15 15 H T T T H 16 16 H T T T T 17 17 T H H H H 18 18 T H H H T 19 19 T H H T H 20 20 T H H T T 21 21 T H T H H 22 22 T H T H T 23 23 T H T T H 24 24 T H T T T 25 25 T T H H H 26 26 T T H H T 27 27 T T H T H 28 28 T T H T T 29 29 T T T H H 30 30 T T T H T 31 31 T T T T H 32 32 T T T T T ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% * add_trials() ``` ] .panel2-veridicalp-auto[ ``` # A tibble: 64 × 7 history t1_outcome t2_outcome t3_outcome t4_outcome t5_outcome t6_outcome <int> <chr> <chr> <chr> <chr> <chr> <chr> 1 1 H H H H H H 2 2 H H H H H T 3 3 H H H H T H 4 4 H H H H T T 5 5 H H H T H H 6 6 H H H T H T 7 7 H H H T T H 8 8 H H H T T T 9 9 H H T H H H 10 10 H H T H H T 11 11 H H T H T H 12 12 H H T H T T 13 13 H H T T H H 14 14 H H T T H T 15 15 H H T T T H 16 16 H H T T T T 17 17 H T H H H H 18 18 H T H H H T 19 19 H T H H T H 20 20 H T H H T T 21 21 H T H T H H 22 22 H T H T H T 23 23 H T H T T H 24 24 H T H T T T 25 25 H T T H H H 26 26 H T T H H T 27 27 H T T H T H 28 28 H T T H T T 29 29 H T T T H H 30 30 H T T T H T 31 31 H T T T T H 32 32 H T T T T T 33 33 T H H H H H 34 34 T H H H H T 35 35 T H H H T H 36 36 T H H H T T 37 37 T H H T H H 38 38 T H H T H T 39 39 T H H T T H 40 40 T H H T T T 41 41 T H T H H H 42 42 T H T H H T 43 43 T H T H T H 44 44 T H T H T T 45 45 T H T T H H 46 46 T H T T H T 47 47 T H T T T H 48 48 T H T T T T 49 49 T T H H H H 50 50 T T H H H T 51 51 T T H H T H 52 52 T T H H T T 53 53 T T H T H H 54 54 T T H T H T 55 55 T T H T T H 56 56 T T H T T T 57 57 T T T H H H 58 58 T T T H H T 59 59 T T T H T H 60 60 T T T H T T 61 61 T T T T H H 62 62 T T T T H T 63 63 T T T T T H 64 64 T T T T T T ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% * to_tsibble() ``` ] .panel2-veridicalp-auto[ ``` # A tibble: 384 × 3 history trial outcome <int> <chr> <chr> 1 1 t1 H 2 1 t2 H 3 1 t3 H 4 1 t4 H 5 1 t5 H 6 1 t6 H 7 2 t1 H 8 2 t2 H 9 2 t3 H 10 2 t4 H 11 2 t5 H 12 2 t6 T 13 3 t1 H 14 3 t2 H 15 3 t3 H 16 3 t4 H 17 3 t5 T 18 3 t6 H 19 4 t1 H 20 4 t2 H 21 4 t3 H 22 4 t4 H 23 4 t5 T 24 4 t6 T 25 5 t1 H 26 5 t2 H 27 5 t3 H 28 5 t4 T 29 5 t5 H 30 5 t6 H 31 6 t1 H 32 6 t2 H 33 6 t3 H 34 6 t4 T 35 6 t5 H 36 6 t6 T 37 7 t1 H 38 7 t2 H 39 7 t3 H 40 7 t4 T 41 7 t5 T 42 7 t6 H 43 8 t1 H 44 8 t2 H 45 8 t3 H 46 8 t4 T 47 8 t5 T 48 8 t6 T 49 9 t1 H 50 9 t2 H 51 9 t3 T 52 9 t4 H 53 9 t5 H 54 9 t6 H 55 10 t1 H 56 10 t2 H 57 10 t3 T 58 10 t4 H 59 10 t5 H 60 10 t6 T 61 11 t1 H 62 11 t2 H 63 11 t3 T 64 11 t4 H 65 11 t5 T 66 11 t6 H 67 12 t1 H 68 12 t2 H 69 12 t3 T 70 12 t4 H 71 12 t5 T 72 12 t6 T 73 13 t1 H 74 13 t2 H 75 13 t3 T 76 13 t4 T 77 13 t5 H 78 13 t6 H 79 14 t1 H 80 14 t2 H 81 14 t3 T 82 14 t4 T 83 14 t5 H 84 14 t6 T 85 15 t1 H 86 15 t2 H 87 15 t3 T 88 15 t4 T 89 15 t5 T 90 15 t6 H 91 16 t1 H 92 16 t2 H 93 16 t3 T 94 16 t4 T 95 16 t5 T 96 16 t6 T 97 17 t1 H 98 17 t2 T 99 17 t3 H 100 17 t4 H 101 17 t5 H 102 17 t6 H 103 18 t1 H 104 18 t2 T 105 18 t3 H 106 18 t4 H 107 18 t5 H 108 18 t6 T 109 19 t1 H 110 19 t2 T 111 19 t3 H 112 19 t4 H 113 19 t5 T 114 19 t6 H 115 20 t1 H 116 20 t2 T 117 20 t3 H 118 20 t4 H 119 20 t5 T 120 20 t6 T 121 21 t1 H 122 21 t2 T 123 21 t3 H 124 21 t4 T 125 21 t5 H 126 21 t6 H 127 22 t1 H 128 22 t2 T 129 22 t3 H 130 22 t4 T 131 22 t5 H 132 22 t6 T 133 23 t1 H 134 23 t2 T 135 23 t3 H 136 23 t4 T 137 23 t5 T 138 23 t6 H 139 24 t1 H 140 24 t2 T 141 24 t3 H 142 24 t4 T 143 24 t5 T 144 24 t6 T 145 25 t1 H 146 25 t2 T 147 25 t3 T 148 25 t4 H 149 25 t5 H 150 25 t6 H 151 26 t1 H 152 26 t2 T 153 26 t3 T 154 26 t4 H 155 26 t5 H 156 26 t6 T 157 27 t1 H 158 27 t2 T 159 27 t3 T 160 27 t4 H 161 27 t5 T 162 27 t6 H 163 28 t1 H 164 28 t2 T 165 28 t3 T 166 28 t4 H 167 28 t5 T 168 28 t6 T 169 29 t1 H 170 29 t2 T 171 29 t3 T 172 29 t4 T 173 29 t5 H 174 29 t6 H 175 30 t1 H 176 30 t2 T 177 30 t3 T 178 30 t4 T 179 30 t5 H 180 30 t6 T 181 31 t1 H 182 31 t2 T 183 31 t3 T 184 31 t4 T 185 31 t5 T 186 31 t6 H 187 32 t1 H 188 32 t2 T 189 32 t3 T 190 32 t4 T 191 32 t5 T 192 32 t6 T 193 33 t1 T 194 33 t2 H 195 33 t3 H 196 33 t4 H 197 33 t5 H 198 33 t6 H 199 34 t1 T 200 34 t2 H 201 34 t3 H 202 34 t4 H 203 34 t5 H 204 34 t6 T 205 35 t1 T 206 35 t2 H 207 35 t3 H 208 35 t4 H 209 35 t5 T 210 35 t6 H 211 36 t1 T 212 36 t2 H 213 36 t3 H 214 36 t4 H 215 36 t5 T 216 36 t6 T 217 37 t1 T 218 37 t2 H 219 37 t3 H 220 37 t4 T 221 37 t5 H 222 37 t6 H 223 38 t1 T 224 38 t2 H 225 38 t3 H 226 38 t4 T 227 38 t5 H 228 38 t6 T 229 39 t1 T 230 39 t2 H 231 39 t3 H 232 39 t4 T 233 39 t5 T 234 39 t6 H 235 40 t1 T 236 40 t2 H 237 40 t3 H 238 40 t4 T 239 40 t5 T 240 40 t6 T 241 41 t1 T 242 41 t2 H 243 41 t3 T 244 41 t4 H 245 41 t5 H 246 41 t6 H 247 42 t1 T 248 42 t2 H 249 42 t3 T 250 42 t4 H 251 42 t5 H 252 42 t6 T 253 43 t1 T 254 43 t2 H 255 43 t3 T 256 43 t4 H 257 43 t5 T 258 43 t6 H 259 44 t1 T 260 44 t2 H 261 44 t3 T 262 44 t4 H 263 44 t5 T 264 44 t6 T 265 45 t1 T 266 45 t2 H 267 45 t3 T 268 45 t4 T 269 45 t5 H 270 45 t6 H 271 46 t1 T 272 46 t2 H 273 46 t3 T 274 46 t4 T 275 46 t5 H 276 46 t6 T 277 47 t1 T 278 47 t2 H 279 47 t3 T 280 47 t4 T 281 47 t5 T 282 47 t6 H 283 48 t1 T 284 48 t2 H 285 48 t3 T 286 48 t4 T 287 48 t5 T 288 48 t6 T 289 49 t1 T 290 49 t2 T 291 49 t3 H 292 49 t4 H 293 49 t5 H 294 49 t6 H 295 50 t1 T 296 50 t2 T 297 50 t3 H 298 50 t4 H 299 50 t5 H 300 50 t6 T 301 51 t1 T 302 51 t2 T 303 51 t3 H 304 51 t4 H 305 51 t5 T 306 51 t6 H 307 52 t1 T 308 52 t2 T 309 52 t3 H 310 52 t4 H 311 52 t5 T 312 52 t6 T 313 53 t1 T 314 53 t2 T 315 53 t3 H 316 53 t4 T 317 53 t5 H 318 53 t6 H 319 54 t1 T 320 54 t2 T 321 54 t3 H 322 54 t4 T 323 54 t5 H 324 54 t6 T 325 55 t1 T 326 55 t2 T 327 55 t3 H 328 55 t4 T 329 55 t5 T 330 55 t6 H 331 56 t1 T 332 56 t2 T 333 56 t3 H 334 56 t4 T 335 56 t5 T 336 56 t6 T 337 57 t1 T 338 57 t2 T 339 57 t3 T 340 57 t4 H 341 57 t5 H 342 57 t6 H 343 58 t1 T 344 58 t2 T 345 58 t3 T 346 58 t4 H 347 58 t5 H 348 58 t6 T 349 59 t1 T 350 59 t2 T 351 59 t3 T 352 59 t4 H 353 59 t5 T 354 59 t6 H 355 60 t1 T 356 60 t2 T 357 60 t3 T 358 60 t4 H 359 60 t5 T 360 60 t6 T 361 61 t1 T 362 61 t2 T 363 61 t3 T 364 61 t4 T 365 61 t5 H 366 61 t6 H 367 62 t1 T 368 62 t2 T 369 62 t3 T 370 62 t4 T 371 62 t5 H 372 62 t6 T 373 63 t1 T 374 63 t2 T 375 63 t3 T 376 63 t4 T 377 63 t5 T 378 63 t6 H 379 64 t1 T 380 64 t2 T 381 64 t3 T 382 64 t4 T 383 64 t5 T 384 64 t6 T ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% * group_by(history) ``` ] .panel2-veridicalp-auto[ ``` # A tibble: 384 × 3 # Groups: history [64] history trial outcome <int> <chr> <chr> 1 1 t1 H 2 1 t2 H 3 1 t3 H 4 1 t4 H 5 1 t5 H 6 1 t6 H 7 2 t1 H 8 2 t2 H 9 2 t3 H 10 2 t4 H 11 2 t5 H 12 2 t6 T 13 3 t1 H 14 3 t2 H 15 3 t3 H 16 3 t4 H 17 3 t5 T 18 3 t6 H 19 4 t1 H 20 4 t2 H 21 4 t3 H 22 4 t4 H 23 4 t5 T 24 4 t6 T 25 5 t1 H 26 5 t2 H 27 5 t3 H 28 5 t4 T 29 5 t5 H 30 5 t6 H 31 6 t1 H 32 6 t2 H 33 6 t3 H 34 6 t4 T 35 6 t5 H 36 6 t6 T 37 7 t1 H 38 7 t2 H 39 7 t3 H 40 7 t4 T 41 7 t5 T 42 7 t6 H 43 8 t1 H 44 8 t2 H 45 8 t3 H 46 8 t4 T 47 8 t5 T 48 8 t6 T 49 9 t1 H 50 9 t2 H 51 9 t3 T 52 9 t4 H 53 9 t5 H 54 9 t6 H 55 10 t1 H 56 10 t2 H 57 10 t3 T 58 10 t4 H 59 10 t5 H 60 10 t6 T 61 11 t1 H 62 11 t2 H 63 11 t3 T 64 11 t4 H 65 11 t5 T 66 11 t6 H 67 12 t1 H 68 12 t2 H 69 12 t3 T 70 12 t4 H 71 12 t5 T 72 12 t6 T 73 13 t1 H 74 13 t2 H 75 13 t3 T 76 13 t4 T 77 13 t5 H 78 13 t6 H 79 14 t1 H 80 14 t2 H 81 14 t3 T 82 14 t4 T 83 14 t5 H 84 14 t6 T 85 15 t1 H 86 15 t2 H 87 15 t3 T 88 15 t4 T 89 15 t5 T 90 15 t6 H 91 16 t1 H 92 16 t2 H 93 16 t3 T 94 16 t4 T 95 16 t5 T 96 16 t6 T 97 17 t1 H 98 17 t2 T 99 17 t3 H 100 17 t4 H 101 17 t5 H 102 17 t6 H 103 18 t1 H 104 18 t2 T 105 18 t3 H 106 18 t4 H 107 18 t5 H 108 18 t6 T 109 19 t1 H 110 19 t2 T 111 19 t3 H 112 19 t4 H 113 19 t5 T 114 19 t6 H 115 20 t1 H 116 20 t2 T 117 20 t3 H 118 20 t4 H 119 20 t5 T 120 20 t6 T 121 21 t1 H 122 21 t2 T 123 21 t3 H 124 21 t4 T 125 21 t5 H 126 21 t6 H 127 22 t1 H 128 22 t2 T 129 22 t3 H 130 22 t4 T 131 22 t5 H 132 22 t6 T 133 23 t1 H 134 23 t2 T 135 23 t3 H 136 23 t4 T 137 23 t5 T 138 23 t6 H 139 24 t1 H 140 24 t2 T 141 24 t3 H 142 24 t4 T 143 24 t5 T 144 24 t6 T 145 25 t1 H 146 25 t2 T 147 25 t3 T 148 25 t4 H 149 25 t5 H 150 25 t6 H 151 26 t1 H 152 26 t2 T 153 26 t3 T 154 26 t4 H 155 26 t5 H 156 26 t6 T 157 27 t1 H 158 27 t2 T 159 27 t3 T 160 27 t4 H 161 27 t5 T 162 27 t6 H 163 28 t1 H 164 28 t2 T 165 28 t3 T 166 28 t4 H 167 28 t5 T 168 28 t6 T 169 29 t1 H 170 29 t2 T 171 29 t3 T 172 29 t4 T 173 29 t5 H 174 29 t6 H 175 30 t1 H 176 30 t2 T 177 30 t3 T 178 30 t4 T 179 30 t5 H 180 30 t6 T 181 31 t1 H 182 31 t2 T 183 31 t3 T 184 31 t4 T 185 31 t5 T 186 31 t6 H 187 32 t1 H 188 32 t2 T 189 32 t3 T 190 32 t4 T 191 32 t5 T 192 32 t6 T 193 33 t1 T 194 33 t2 H 195 33 t3 H 196 33 t4 H 197 33 t5 H 198 33 t6 H 199 34 t1 T 200 34 t2 H 201 34 t3 H 202 34 t4 H 203 34 t5 H 204 34 t6 T 205 35 t1 T 206 35 t2 H 207 35 t3 H 208 35 t4 H 209 35 t5 T 210 35 t6 H 211 36 t1 T 212 36 t2 H 213 36 t3 H 214 36 t4 H 215 36 t5 T 216 36 t6 T 217 37 t1 T 218 37 t2 H 219 37 t3 H 220 37 t4 T 221 37 t5 H 222 37 t6 H 223 38 t1 T 224 38 t2 H 225 38 t3 H 226 38 t4 T 227 38 t5 H 228 38 t6 T 229 39 t1 T 230 39 t2 H 231 39 t3 H 232 39 t4 T 233 39 t5 T 234 39 t6 H 235 40 t1 T 236 40 t2 H 237 40 t3 H 238 40 t4 T 239 40 t5 T 240 40 t6 T 241 41 t1 T 242 41 t2 H 243 41 t3 T 244 41 t4 H 245 41 t5 H 246 41 t6 H 247 42 t1 T 248 42 t2 H 249 42 t3 T 250 42 t4 H 251 42 t5 H 252 42 t6 T 253 43 t1 T 254 43 t2 H 255 43 t3 T 256 43 t4 H 257 43 t5 T 258 43 t6 H 259 44 t1 T 260 44 t2 H 261 44 t3 T 262 44 t4 H 263 44 t5 T 264 44 t6 T 265 45 t1 T 266 45 t2 H 267 45 t3 T 268 45 t4 T 269 45 t5 H 270 45 t6 H 271 46 t1 T 272 46 t2 H 273 46 t3 T 274 46 t4 T 275 46 t5 H 276 46 t6 T 277 47 t1 T 278 47 t2 H 279 47 t3 T 280 47 t4 T 281 47 t5 T 282 47 t6 H 283 48 t1 T 284 48 t2 H 285 48 t3 T 286 48 t4 T 287 48 t5 T 288 48 t6 T 289 49 t1 T 290 49 t2 T 291 49 t3 H 292 49 t4 H 293 49 t5 H 294 49 t6 H 295 50 t1 T 296 50 t2 T 297 50 t3 H 298 50 t4 H 299 50 t5 H 300 50 t6 T 301 51 t1 T 302 51 t2 T 303 51 t3 H 304 51 t4 H 305 51 t5 T 306 51 t6 H 307 52 t1 T 308 52 t2 T 309 52 t3 H 310 52 t4 H 311 52 t5 T 312 52 t6 T 313 53 t1 T 314 53 t2 T 315 53 t3 H 316 53 t4 T 317 53 t5 H 318 53 t6 H 319 54 t1 T 320 54 t2 T 321 54 t3 H 322 54 t4 T 323 54 t5 H 324 54 t6 T 325 55 t1 T 326 55 t2 T 327 55 t3 H 328 55 t4 T 329 55 t5 T 330 55 t6 H 331 56 t1 T 332 56 t2 T 333 56 t3 H 334 56 t4 T 335 56 t5 T 336 56 t6 T 337 57 t1 T 338 57 t2 T 339 57 t3 T 340 57 t4 H 341 57 t5 H 342 57 t6 H 343 58 t1 T 344 58 t2 T 345 58 t3 T 346 58 t4 H 347 58 t5 H 348 58 t6 T 349 59 t1 T 350 59 t2 T 351 59 t3 T 352 59 t4 H 353 59 t5 T 354 59 t6 H 355 60 t1 T 356 60 t2 T 357 60 t3 T 358 60 t4 H 359 60 t5 T 360 60 t6 T 361 61 t1 T 362 61 t2 T 363 61 t3 T 364 61 t4 T 365 61 t5 H 366 61 t6 H 367 62 t1 T 368 62 t2 T 369 62 t3 T 370 62 t4 T 371 62 t5 H 372 62 t6 T 373 63 t1 T 374 63 t2 T 375 63 t3 T 376 63 t4 T 377 63 t5 T 378 63 t6 H 379 64 t1 T 380 64 t2 T 381 64 t3 T 382 64 t4 T 383 64 t5 T 384 64 t6 T ``` ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% * ggplot() ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_12_output-1.png)<!-- --> ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + * aes(y = history, x = trial) ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_13_output-1.png)<!-- --> ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + * geom_tile(color = "white") ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_14_output-1.png)<!-- --> ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + * aes(fill = outcome) ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_15_output-1.png)<!-- --> ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> *baseplot ``` ] .panel2-veridicalp-auto[ ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> baseplot *baseplot ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_17_output-1.png)<!-- --> ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> baseplot baseplot + * geom_point(data = . %>% * filter( outcome == "H" & * lag(outcome) == "H"), * color = "darkred") ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_18_output-1.png)<!-- --> ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> baseplot baseplot + geom_point(data = . %>% filter( outcome == "H" & lag(outcome) == "H"), color = "darkred") -> * heads_heads ``` ] .panel2-veridicalp-auto[ ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> baseplot baseplot + geom_point(data = . %>% filter( outcome == "H" & lag(outcome) == "H"), color = "darkred") -> heads_heads *baseplot ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_20_output-1.png)<!-- --> ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> baseplot baseplot + geom_point(data = . %>% filter( outcome == "H" & lag(outcome) == "H"), color = "darkred") -> heads_heads baseplot + * geom_point(data = . %>% * filter( outcome == "T" & * lag(outcome) == "H"), * color = "darkred") ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_21_output-1.png)<!-- --> ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> baseplot baseplot + geom_point(data = . %>% filter( outcome == "H" & lag(outcome) == "H"), color = "darkred") -> heads_heads baseplot + geom_point(data = . %>% filter( outcome == "T" & lag(outcome) == "H"), color = "darkred") -> * heads_tails ``` ] .panel2-veridicalp-auto[ ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> baseplot baseplot + geom_point(data = . %>% filter( outcome == "H" & lag(outcome) == "H"), color = "darkred") -> heads_heads baseplot + geom_point(data = . %>% filter( outcome == "T" & lag(outcome) == "H"), color = "darkred") -> heads_tails *library(patchwork) ``` ] .panel2-veridicalp-auto[ ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> baseplot baseplot + geom_point(data = . %>% filter( outcome == "H" & lag(outcome) == "H"), color = "darkred") -> heads_heads baseplot + geom_point(data = . %>% filter( outcome == "T" & lag(outcome) == "H"), color = "darkred") -> heads_tails library(patchwork) *heads_heads + heads_tails ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_24_output-1.png)<!-- --> ] --- count: false .panel1-veridicalp-auto[ ```r options(pillar.print_max = Inf) fair_coin(outcome_set = c("T", "H")) %>% select(-prob) %>% trial_init() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% add_trials() %>% to_tsibble() %>% group_by(history) %>% ggplot() + aes(y = history, x = trial) + geom_tile(color = "white") + aes(fill = outcome) -> baseplot baseplot + geom_point(data = . %>% filter( outcome == "H" & lag(outcome) == "H"), color = "darkred") -> heads_heads baseplot + geom_point(data = . %>% filter( outcome == "T" & lag(outcome) == "H"), color = "darkred") -> heads_tails library(patchwork) heads_heads + heads_tails ``` ] .panel2-veridicalp-auto[ ![](advanced_pivoting_files/figure-html/veridicalp_auto_25_output-1.png)<!-- --> ] <style> .panel1-veridicalp-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-veridicalp-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-veridicalp-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> <style type="text/css"> .remark-code{line-height: 1.5; font-size: 80%} @media print { .has-continuation { display: block; } } code.r.hljs.remark-code{ position: relative; overflow-x: hidden; } code.r.hljs.remark-code:hover{ overflow-x:visible; width: 500px; border-style: solid; } </style>