class: center, middle, inverse, title-slide # Ex. 4.1: Column Chart --- count: false .panel1-the_chunk-auto[ ```r *employed_under_150K ``` ] .panel2-the_chunk-auto[ ``` # A tibble: 80,635 x 5 Earnings Earnings_per_member Sex Age Education <dbl> <dbl> <chr> <dbl> <chr> 1 8000 1600 F 20 Less than HS 2 4000 800 M 16 Less than HS 3 17350 8675 M 27 Less than HS 4 12000 6000 M 24 Less than HS 5 25480 25480 M 62 Bachelors 6 6000 1000 F 53 Bachelors 7 70200 11700 M 52 Bachelors 8 10520 1753. F 16 Less than HS 9 46000 11500 F 31 Some College/Associates 10 40000 40000 M 37 Less than HS # … with 80,625 more rows ``` ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% * group_by(Education, Sex) ``` ] .panel2-the_chunk-auto[ ``` # A tibble: 80,635 x 5 # Groups: Education, Sex [12] Earnings Earnings_per_member Sex Age Education <dbl> <dbl> <chr> <dbl> <chr> 1 8000 1600 F 20 Less than HS 2 4000 800 M 16 Less than HS 3 17350 8675 M 27 Less than HS 4 12000 6000 M 24 Less than HS 5 25480 25480 M 62 Bachelors 6 6000 1000 F 53 Bachelors 7 70200 11700 M 52 Bachelors 8 10520 1753. F 16 Less than HS 9 46000 11500 F 31 Some College/Associates 10 40000 40000 M 37 Less than HS # … with 80,625 more rows ``` ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% * summarize(mean_earnings = mean(Earnings)) ``` ] .panel2-the_chunk-auto[ ``` # A tibble: 12 x 3 # Groups: Education [6] Education Sex mean_earnings <chr> <chr> <dbl> 1 Bachelors F 59671. 2 Bachelors M 72490. 3 HS Graduate F 35975. 4 HS Graduate M 51562. 5 Less than HS F 26219. 6 Less than HS M 39054. 7 Masters F 71574. 8 Masters M 75107. 9 PhD/MD/JD F 71439. 10 PhD/MD/JD M 76585. 11 Some College/Associates F 47555. 12 Some College/Associates M 62906. ``` ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% * mutate(Education = factor(Education, * levels = c("Less than HS", * "HS Graduate", * "Some College/Associates", * "Bachelors", * "Masters", * "PhD/MD/JD"))) ``` ] .panel2-the_chunk-auto[ ``` # A tibble: 12 x 3 # Groups: Education [6] Education Sex mean_earnings <fct> <chr> <dbl> 1 Bachelors F 59671. 2 Bachelors M 72490. 3 HS Graduate F 35975. 4 HS Graduate M 51562. 5 Less than HS F 26219. 6 Less than HS M 39054. 7 Masters F 71574. 8 Masters M 75107. 9 PhD/MD/JD F 71439. 10 PhD/MD/JD M 76585. 11 Some College/Associates F 47555. 12 Some College/Associates M 62906. ``` ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% * ggplot() ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_05_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% ggplot() + * aes(x = mean_earnings) ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_06_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% ggplot() + aes(x = mean_earnings) + * aes(y = Education) ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_07_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% ggplot() + aes(x = mean_earnings) + aes(y = Education) + * geom_col(position = "dodge") ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_08_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% ggplot() + aes(x = mean_earnings) + aes(y = Education) + geom_col(position = "dodge") + * aes(fill = Sex) ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_09_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% ggplot() + aes(x = mean_earnings) + aes(y = Education) + geom_col(position = "dodge") + aes(fill = Sex) + * labs(x = "Mean Earnings (USD)") ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_10_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% ggplot() + aes(x = mean_earnings) + aes(y = Education) + geom_col(position = "dodge") + aes(fill = Sex) + labs(x = "Mean Earnings (USD)") + * labs(y = "Count") ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_11_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% ggplot() + aes(x = mean_earnings) + aes(y = Education) + geom_col(position = "dodge") + aes(fill = Sex) + labs(x = "Mean Earnings (USD)") + labs(y = "Count") + * labs(title = * "Column Chart of Mean Earnings by Education") ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_12_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% ggplot() + aes(x = mean_earnings) + aes(y = Education) + geom_col(position = "dodge") + aes(fill = Sex) + labs(x = "Mean Earnings (USD)") + labs(y = "Count") + labs(title = "Column Chart of Mean Earnings by Education") + * labs(subtitle = * "Divided by Share of Each Sex") ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_13_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Education, Sex) %>% summarize(mean_earnings = mean(Earnings)) %>% mutate(Education = factor(Education, levels = c("Less than HS", "HS Graduate", "Some College/Associates", "Bachelors", "Masters", "PhD/MD/JD"))) %>% ggplot() + aes(x = mean_earnings) + aes(y = Education) + geom_col(position = "dodge") + aes(fill = Sex) + labs(x = "Mean Earnings (USD)") + labs(y = "Count") + labs(title = "Column Chart of Mean Earnings by Education") + labs(subtitle = "Divided by Share of Each Sex") + * scale_x_continuous(labels = scales::comma) ``` ] .panel2-the_chunk-auto[ <img src="ex4.1_embed_files/figure-html/the_chunk_auto_14_output-1.png" width="576" /> ] <style> .panel1-the_chunk-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel2-the_chunk-auto { color: black; width: 49%; hight: 32%; float: left; padding-left: 1%; font-size: 80% } .panel3-the_chunk-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: 90%} @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>