Discuss the following questions for each visualization:
Figure from the New York Times “What’s Going on with this Graph?” series.
Figure originally seen on Twitter.
Click on the link provided in the slides to create your own private repo for this exercise.
Go to the appex-02-[GITHUB USERNAME] repo on GitHub
that you created
Click on the green Code button, Use HTTPS, and click on the clipboard icon to copy the repo URL.
Open up RStudio
Go to File \(\rightarrow\) New Project \(\rightarrow\) Version Control \(\rightarrow\) Git.
Copy and paste the URL of your assignment repo into the dialog box Repository URL. You can leave Project Directory Name empty. It will default to the name of the GitHub repo. In Create project as a subdirectory of, hit “Browse” and find your Math118 folder.
Click Create Project, and the files from your GitHub repo will be displayed the Files pane in RStudio.
Modify the following plot to change the color of all points to
"pink". Knit the document to observe the
changes by hitting the “Knit” button at the top of your markdown
editor:
ggplot(data = starwars,
mapping = aes(x = height, y = mass, color = gender, size = birth_year)) +
geom_point(color = "#30509C") +
labs(title = "_____" , size = "_____", x = "_____", y = "_____")
## Warning: Removed 51 rows containing missing values (geom_point).
Add labels for title, x and y axes, and size of points. Knit again.
Fill in the code below to make a histogram of a numerical variable of
your choice. Once you have modified the code, remove the option
eval = FALSE from the code chunk header. Knit again to see
the updates.
See the ggplot2 reference page for help to create histograms.
ggplot(data = starwars,
mapping = aes(x = _____)) +
___________ +
labs(title = "_____" , x = "_____", y = "_____")
Modify the histogram by adding color = "blue" inside
of the geom_XX function. (Feel free to use a different
color besides blue!) Knit to see the updated histogram.
Now modify the histogram by adding fill = "orange"
inside of the geom_XX function. (Feel free to use a different color
besides orange!) Knit to see the updated histogram.
What is the difference between color and
fill?
If you made any changes since the last knit, knit again to get the final version of the AE.
Check the box next to each document in the Git tab (this is called “staging” the changes). Commit the changes you made using an simple and informative message.
Use the green arrow to push your changes to your repo on GitHub.
Check your repo on GitHub and see the updated files.
This exercise was modified from “Starwars + Data visualization” in Data Science in Box.