Discuss the following questions for each visualization:
Click on the link provided in the slides to create your own private repo for this exercise.
Go to the ae-03-[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.
Go to https://vm-manage.oit.duke.edu/containers and login with your Duke NetID and Password. Click to log into the Docker container RStudio - statistics application with Rmarkdown and knitr support. You should now see the RStudio environment.
Go to File ➡️ New Project ➡️ Version Control ➡️ 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.
Click Create Project, and the files from your GitHub repo will be displayed the Files pane in RStudio.
Before we start the exercise, we need to configure your git so that RStudio can communicate with GitHub. This requires two pieces of information: your email address and your name.
Type the following lines of code in the Console in RStudio filling in your GitHub username and email address associated with your GitHub account.
library(usethis)
use_git_config(user.name= "github username", user.email="your email")
RStudio and GitHub can now communicate with each other and you are ready to do the exercise!
Modify the following plot to change the color of all points to "pink"
. Knit the document to observe the changes.
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 = "pink"
inside of the geom_XX function. (Feel free to use a different color besides pink!) 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.