class: center, middle, inverse, title-slide # Exploded code ## Using flipbookr and xaringan ### Me --- <style type="text/css"> .remark-code{line-height: 1.5; font-size: 100%} @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> --- count: false .panel1-setup-auto[ ```r *library(tidyverse) ``` ] .panel2-setup-auto[ ] --- count: false .panel1-setup-auto[ ```r library(tidyverse) *knitr::opts_chunk$set(echo = TRUE) ``` ] .panel2-setup-auto[ ] <style> .panel1-setup-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-setup-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-setup-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style> --- count: false .panel1-anscombe-auto[ ```r *datasets::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 datasets::anscombe %>% * pivot_longer(cols = 1:8) ``` ] .panel2-anscombe-auto[ ``` # A tibble: 88 x 2 name value <chr> <dbl> 1 x1 10 2 x2 10 3 x3 10 4 x4 8 5 y1 8.04 6 y2 9.14 7 y3 7.46 8 y4 6.58 9 x1 8 10 x2 8 11 x3 8 12 x4 8 13 y1 6.95 14 y2 8.14 15 y3 6.77 16 y4 5.76 17 x1 13 18 x2 13 19 x3 13 20 x4 8 21 y1 7.58 22 y2 8.74 23 y3 12.7 24 y4 7.71 25 x1 9 26 x2 9 27 x3 9 28 x4 8 29 y1 8.81 30 y2 8.77 31 y3 7.11 32 y4 8.84 33 x1 11 34 x2 11 35 x3 11 36 x4 8 37 y1 8.33 38 y2 9.26 39 y3 7.81 40 y4 8.47 41 x1 14 42 x2 14 43 x3 14 44 x4 8 45 y1 9.96 46 y2 8.1 47 y3 8.84 48 y4 7.04 49 x1 6 50 x2 6 51 x3 6 52 x4 8 53 y1 7.24 54 y2 6.13 55 y3 6.08 # … with 33 more rows ``` ] --- count: false .panel1-anscombe-auto[ ```r datasets::anscombe %>% pivot_longer(cols = 1:8) %>% * mutate(group = str_extract(name, "\\d")) ``` ] .panel2-anscombe-auto[ ``` # A tibble: 88 x 3 name value group <chr> <dbl> <chr> 1 x1 10 1 2 x2 10 2 3 x3 10 3 4 x4 8 4 5 y1 8.04 1 6 y2 9.14 2 7 y3 7.46 3 8 y4 6.58 4 9 x1 8 1 10 x2 8 2 11 x3 8 3 12 x4 8 4 13 y1 6.95 1 14 y2 8.14 2 15 y3 6.77 3 16 y4 5.76 4 17 x1 13 1 18 x2 13 2 19 x3 13 3 20 x4 8 4 21 y1 7.58 1 22 y2 8.74 2 23 y3 12.7 3 24 y4 7.71 4 25 x1 9 1 26 x2 9 2 27 x3 9 3 28 x4 8 4 29 y1 8.81 1 30 y2 8.77 2 31 y3 7.11 3 32 y4 8.84 4 33 x1 11 1 34 x2 11 2 35 x3 11 3 36 x4 8 4 37 y1 8.33 1 38 y2 9.26 2 39 y3 7.81 3 40 y4 8.47 4 41 x1 14 1 42 x2 14 2 43 x3 14 3 44 x4 8 4 45 y1 9.96 1 46 y2 8.1 2 47 y3 8.84 3 48 y4 7.04 4 49 x1 6 1 50 x2 6 2 51 x3 6 3 52 x4 8 4 53 y1 7.24 1 54 y2 6.13 2 55 y3 6.08 3 # … with 33 more rows ``` ] --- count: false .panel1-anscombe-auto[ ```r datasets::anscombe %>% pivot_longer(cols = 1:8) %>% mutate(group = str_extract(name, "\\d")) %>% * mutate(var = str_extract(name, "\\w")) ``` ] .panel2-anscombe-auto[ ``` # A tibble: 88 x 4 name value group var <chr> <dbl> <chr> <chr> 1 x1 10 1 x 2 x2 10 2 x 3 x3 10 3 x 4 x4 8 4 x 5 y1 8.04 1 y 6 y2 9.14 2 y 7 y3 7.46 3 y 8 y4 6.58 4 y 9 x1 8 1 x 10 x2 8 2 x 11 x3 8 3 x 12 x4 8 4 x 13 y1 6.95 1 y 14 y2 8.14 2 y 15 y3 6.77 3 y 16 y4 5.76 4 y 17 x1 13 1 x 18 x2 13 2 x 19 x3 13 3 x 20 x4 8 4 x 21 y1 7.58 1 y 22 y2 8.74 2 y 23 y3 12.7 3 y 24 y4 7.71 4 y 25 x1 9 1 x 26 x2 9 2 x 27 x3 9 3 x 28 x4 8 4 x 29 y1 8.81 1 y 30 y2 8.77 2 y 31 y3 7.11 3 y 32 y4 8.84 4 y 33 x1 11 1 x 34 x2 11 2 x 35 x3 11 3 x 36 x4 8 4 x 37 y1 8.33 1 y 38 y2 9.26 2 y 39 y3 7.81 3 y 40 y4 8.47 4 y 41 x1 14 1 x 42 x2 14 2 x 43 x3 14 3 x 44 x4 8 4 x 45 y1 9.96 1 y 46 y2 8.1 2 y 47 y3 8.84 3 y 48 y4 7.04 4 y 49 x1 6 1 x 50 x2 6 2 x 51 x3 6 3 x 52 x4 8 4 x 53 y1 7.24 1 y 54 y2 6.13 2 y 55 y3 6.08 3 y # … with 33 more rows ``` ] --- count: false .panel1-anscombe-auto[ ```r datasets::anscombe %>% pivot_longer(cols = 1:8) %>% mutate(group = str_extract(name, "\\d")) %>% mutate(var = str_extract(name, "\\w")) %>% * select(-name) ``` ] .panel2-anscombe-auto[ ``` # A tibble: 88 x 3 value group var <dbl> <chr> <chr> 1 10 1 x 2 10 2 x 3 10 3 x 4 8 4 x 5 8.04 1 y 6 9.14 2 y 7 7.46 3 y 8 6.58 4 y 9 8 1 x 10 8 2 x 11 8 3 x 12 8 4 x 13 6.95 1 y 14 8.14 2 y 15 6.77 3 y 16 5.76 4 y 17 13 1 x 18 13 2 x 19 13 3 x 20 8 4 x 21 7.58 1 y 22 8.74 2 y 23 12.7 3 y 24 7.71 4 y 25 9 1 x 26 9 2 x 27 9 3 x 28 8 4 x 29 8.81 1 y 30 8.77 2 y 31 7.11 3 y 32 8.84 4 y 33 11 1 x 34 11 2 x 35 11 3 x 36 8 4 x 37 8.33 1 y 38 9.26 2 y 39 7.81 3 y 40 8.47 4 y 41 14 1 x 42 14 2 x 43 14 3 x 44 8 4 x 45 9.96 1 y 46 8.1 2 y 47 8.84 3 y 48 7.04 4 y 49 6 1 x 50 6 2 x 51 6 3 x 52 8 4 x 53 7.24 1 y 54 6.13 2 y 55 6.08 3 y # … with 33 more rows ``` ] --- count: false .panel1-anscombe-auto[ ```r datasets::anscombe %>% pivot_longer(cols = 1:8) %>% mutate(group = str_extract(name, "\\d")) %>% mutate(var = str_extract(name, "\\w")) %>% select(-name) %>% * pivot_wider(names_from = var, * values_from = value) ``` ] .panel2-anscombe-auto[ ``` # A tibble: 4 x 3 group x y <chr> <list> <list> 1 1 <dbl [11]> <dbl [11]> 2 2 <dbl [11]> <dbl [11]> 3 3 <dbl [11]> <dbl [11]> 4 4 <dbl [11]> <dbl [11]> ``` ] --- count: false .panel1-anscombe-auto[ ```r datasets::anscombe %>% pivot_longer(cols = 1:8) %>% mutate(group = str_extract(name, "\\d")) %>% mutate(var = str_extract(name, "\\w")) %>% select(-name) %>% pivot_wider(names_from = var, values_from = value) %>% * unnest() ``` ] .panel2-anscombe-auto[ ``` # A tibble: 44 x 3 group 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 11 1 5 5.68 12 2 10 9.14 13 2 8 8.14 14 2 13 8.74 15 2 9 8.77 16 2 11 9.26 17 2 14 8.1 18 2 6 6.13 19 2 4 3.1 20 2 12 9.13 21 2 7 7.26 22 2 5 4.74 23 3 10 7.46 24 3 8 6.77 25 3 13 12.7 26 3 9 7.11 27 3 11 7.81 28 3 14 8.84 29 3 6 6.08 30 3 4 5.39 31 3 12 8.15 32 3 7 6.42 33 3 5 5.73 34 4 8 6.58 35 4 8 5.76 36 4 8 7.71 37 4 8 8.84 38 4 8 8.47 39 4 8 7.04 40 4 8 5.25 41 4 19 12.5 42 4 8 5.56 43 4 8 7.91 44 4 8 6.89 ``` ] --- count: false .panel1-anscombe-auto[ ```r datasets::anscombe %>% pivot_longer(cols = 1:8) %>% mutate(group = str_extract(name, "\\d")) %>% mutate(var = str_extract(name, "\\w")) %>% select(-name) %>% pivot_wider(names_from = var, values_from = value) %>% unnest() -> *tidy_anscombe ``` ] .panel2-anscombe-auto[ ] <style> .panel1-anscombe-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-anscombe-auto { color: black; width: 49%; 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-anscombe_plot-auto[ ```r *tidy_anscombe ``` ] .panel2-anscombe_plot-auto[ ``` # A tibble: 44 x 3 group 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 11 1 5 5.68 12 2 10 9.14 13 2 8 8.14 14 2 13 8.74 15 2 9 8.77 16 2 11 9.26 17 2 14 8.1 18 2 6 6.13 19 2 4 3.1 20 2 12 9.13 21 2 7 7.26 22 2 5 4.74 23 3 10 7.46 24 3 8 6.77 25 3 13 12.7 26 3 9 7.11 27 3 11 7.81 28 3 14 8.84 29 3 6 6.08 30 3 4 5.39 31 3 12 8.15 32 3 7 6.42 33 3 5 5.73 34 4 8 6.58 35 4 8 5.76 36 4 8 7.71 37 4 8 8.84 38 4 8 8.47 39 4 8 7.04 40 4 8 5.25 41 4 19 12.5 42 4 8 5.56 43 4 8 7.91 44 4 8 6.89 ``` ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% * ggplot() ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_02_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + * aes(x = x, y = y) ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_03_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + * geom_point() ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_04_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + geom_point() + * aes(color = group) ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_05_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + geom_point() + aes(color = group) + * facet_wrap(facets = vars(group)) ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_06_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + geom_point() + aes(color = group) + facet_wrap(facets = vars(group)) + # mean of x * ggxmean::geom_x_mean() ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_07_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + geom_point() + aes(color = group) + facet_wrap(facets = vars(group)) + # mean of x ggxmean::geom_x_mean() + * ggxmean::geom_y_mean() ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_08_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + geom_point() + aes(color = group) + facet_wrap(facets = vars(group)) + # mean of x ggxmean::geom_x_mean() + ggxmean::geom_y_mean() + # mean of y * ggxmean:::geom_x1sd(linetype = "dashed") ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_09_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + geom_point() + aes(color = group) + facet_wrap(facets = vars(group)) + # mean of x ggxmean::geom_x_mean() + ggxmean::geom_y_mean() + # mean of y ggxmean:::geom_x1sd(linetype = "dashed") + * ggxmean:::geom_y1sd(linetype = "dashed") ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_10_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + geom_point() + aes(color = group) + facet_wrap(facets = vars(group)) + # mean of x ggxmean::geom_x_mean() + ggxmean::geom_y_mean() + # mean of y ggxmean:::geom_x1sd(linetype = "dashed") + ggxmean:::geom_y1sd(linetype = "dashed") + # linear model * ggxmean::geom_lm() ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_11_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + geom_point() + aes(color = group) + facet_wrap(facets = vars(group)) + # mean of x ggxmean::geom_x_mean() + ggxmean::geom_y_mean() + # mean of y ggxmean:::geom_x1sd(linetype = "dashed") + ggxmean:::geom_y1sd(linetype = "dashed") + # linear model ggxmean::geom_lm() + * ggxmean::geom_lm_formula() ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_12_output-1.png)<!-- --> ] --- count: false .panel1-anscombe_plot-auto[ ```r tidy_anscombe %>% ggplot() + aes(x = x, y = y) + geom_point() + aes(color = group) + facet_wrap(facets = vars(group)) + # mean of x ggxmean::geom_x_mean() + ggxmean::geom_y_mean() + # mean of y ggxmean:::geom_x1sd(linetype = "dashed") + ggxmean:::geom_y1sd(linetype = "dashed") + # linear model ggxmean::geom_lm() + ggxmean::geom_lm_formula() + # Pearson correlation * ggxmean:::geom_corrlabel() ``` ] .panel2-anscombe_plot-auto[ ![](anscombes_exploded_files/figure-html/anscombe_plot_auto_13_output-1.png)<!-- --> ] <style> .panel1-anscombe_plot-auto { color: black; width: 38.6060606060606%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-anscombe_plot-auto { color: black; width: 59.3939393939394%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-anscombe_plot-auto { color: black; width: NA%; hight: 33%; float: left; padding-left: 1%; font-size: 80% } </style>