class: center, middle, inverse, title-slide # Ex. 2.3: Building Your Plot ## Line Plot --- 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(Age) ``` ] .panel2-the_chunk-auto[ ``` # A tibble: 80,635 x 5 # Groups: Age [67] 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(Age) %>% * summarise(Median = median(Earnings)) ``` ] .panel2-the_chunk-auto[ ``` # A tibble: 67 x 2 Age Median <dbl> <dbl> 1 15 1500 2 16 2000 3 17 3000 4 18 5000 5 19 8550 6 20 11000 7 21 15000 8 22 17960 9 23 20800 10 24 24000 # … with 57 more rows ``` ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% * ggplot() ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_04_output-1.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + * aes(x = Age) ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_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(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + * aes(y = Median) ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_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(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + * geom_line() ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_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(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + * labs(x="Age (Years)") ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_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(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + * labs(y="Earnings (USD)") ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_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(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + * labs(title = "Age vs. Median Earnings") ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_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(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") *employed_under_150K ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_11_output-1.png" width="576" /> ``` # 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(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% * group_by(Age, Sex) ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_12_output-1.png" width="576" /> ``` # A tibble: 80,635 x 5 # Groups: Age, Sex [134] 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(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% group_by(Age, Sex) %>% * summarise(Median = median(Earnings)) ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_13_output-1.png" width="576" /> ``` # A tibble: 134 x 3 # Groups: Age [67] Age Sex Median <dbl> <chr> <dbl> 1 15 F 1500 2 15 M 1500 3 16 F 2000 4 16 M 2000 5 17 F 2880 6 17 M 3200 7 18 F 4600 8 18 M 5000 9 19 F 7626. 10 19 M 10000 # … with 124 more rows ``` ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% group_by(Age, Sex) %>% summarise(Median = median(Earnings)) %>% * ggplot() ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_14_output-1.png" width="576" /><img src="ex2.3_embed_files/figure-html/the_chunk_auto_14_output-2.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% group_by(Age, Sex) %>% summarise(Median = median(Earnings)) %>% ggplot() + * aes(x = Age) ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_15_output-1.png" width="576" /><img src="ex2.3_embed_files/figure-html/the_chunk_auto_15_output-2.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% group_by(Age, Sex) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + * aes(y = Median) ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_16_output-1.png" width="576" /><img src="ex2.3_embed_files/figure-html/the_chunk_auto_16_output-2.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% group_by(Age, Sex) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + * aes(color = Sex) ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_17_output-1.png" width="576" /><img src="ex2.3_embed_files/figure-html/the_chunk_auto_17_output-2.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% group_by(Age, Sex) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + aes(color = Sex) + * geom_line() ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_18_output-1.png" width="576" /><img src="ex2.3_embed_files/figure-html/the_chunk_auto_18_output-2.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% group_by(Age, Sex) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + aes(color = Sex) + geom_line() + * labs(x="Age (Years)") ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_19_output-1.png" width="576" /><img src="ex2.3_embed_files/figure-html/the_chunk_auto_19_output-2.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% group_by(Age, Sex) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + aes(color = Sex) + geom_line() + labs(x="Age (Years)") + * labs(y="Earnings (USD)") ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_20_output-1.png" width="576" /><img src="ex2.3_embed_files/figure-html/the_chunk_auto_20_output-2.png" width="576" /> ] --- count: false .panel1-the_chunk-auto[ ```r employed_under_150K %>% group_by(Age) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + labs(title = "Age vs. Median Earnings") employed_under_150K %>% group_by(Age, Sex) %>% summarise(Median = median(Earnings)) %>% ggplot() + aes(x = Age) + aes(y = Median) + aes(color = Sex) + geom_line() + labs(x="Age (Years)") + labs(y="Earnings (USD)") + * labs(title = "Age vs. Median Earnings by Sex") ``` ] .panel2-the_chunk-auto[ <img src="ex2.3_embed_files/figure-html/the_chunk_auto_21_output-1.png" width="576" /><img src="ex2.3_embed_files/figure-html/the_chunk_auto_21_output-2.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>