@@ -612,13 +612,10 @@ n.o.s. with over 60,000 Canadian residents reporting it as their mother tongue.
612
612
### Putting it all together
613
613
614
614
In the block of code below, we put everything from this chapter together, with a few
615
- modifications. In particular, we have
616
- added a few more layers to make the data visualization even more effective.
617
- Specifically, we changed the color of the bars and changed the background from
618
- grey to white to improve the contrast. We have also actually skipped the
615
+ modifications. In particular, we have actually skipped the
619
616
` select ` step that we did above; since you specify the variable names to plot
620
617
in the ` ggplot ` function, you don't actually need to ` select ` the columns in advance
621
- when creating a visualization. And finally, we provided * comments* next to
618
+ when creating a visualization. We have also provided * comments* next to
622
619
many of the lines of code below using the
623
620
hash symbol ` # ` . When R sees a ` # ` sign, \index{comment} \index{aaacommentsymb@\# |see{comment}} it
624
621
will ignore all of the text that
@@ -641,17 +638,16 @@ ten_lang <- slice(arranged_lang, 1:10)
641
638
# create the visualization
642
639
ggplot(ten_lang, aes(x = mother_tongue,
643
640
y = reorder(language, mother_tongue))) +
644
- geom_bar(stat = "identity", fill = "steelblue" ) +
641
+ geom_bar(stat = "identity") +
645
642
xlab("Mother Tongue (Number of Canadians, 2016 Census)") +
646
- ylab("Language") +
647
- theme_bw() # use a theme to have a white background
643
+ ylab("Language")
648
644
```
649
645
650
646
This exercise demonstrates the power of R. In relatively few lines of code, we
651
647
performed an entire data science workflow with a highly effective data
652
648
visualization! We asked a question, loaded the data into R, wrangled the data
653
649
(using ` filter ` , ` arrange ` and ` slice ` ) and created a data visualization to
654
- help answer our question. In this chapter, you got a quick taste of the data
650
+ help answer our question. In this chapter, you got a quick taste of the data
655
651
science workflow; continue on with the next few chapters to learn each of
656
652
these steps in much more detail!
657
653
0 commit comments