Week 7: In-Class Assignment
PART 1: DataViz to find errors
Dataset for part 1: las_data_viz.csv
Code: the code used in class is at the bottom of this page. You can also download it here. Either download a zip file containing the .r file (“download zip” button in the top right corner), or click the “raw” button to open the code in a web browser; you can then “copy-and-paste” this into an R script.
PART 2: How to make really ugly plots
- Here are three datasets to download for this part of the session. Save to your RStudio Project.
cereal.csv: data on the nutritional content of different breakfast cereals.
bites.csv: Data on dogs bites by breed.
bigfoot.csv: Number of Bigfoot sightings per year in North America
We’re going to make a bar plot, then a scatter plot. First you read in the data using
read_csv()
:bites <- read_csv("./-------")
bigfoot <- read_csv("./-------")
Now that we’ve learned about making basic figures, your job is to make a figure that is as ugly as possible. If you need some inspiration, check out these examples!
Submit them via canvas, and we will vote on the best (=worst) one next week!
Here are some resources that will really help today:
- The R Graph Gallery
- ggplot manual from R Studio
- R Charts with code
- R Graphics Book
- A Cheat Sheet of all the colors in Base R
- all the shapes of aesthetics (lines, points, etc)
And if you really want to go wild:
Want to add background images to your plots? Here’s how.
BTW, I’ll be posting these to the RESOURCES page for the session later, along with some other things.
“Ch7 in Exploratory Data Analysis” in Wickham and Grolemund’s “R for Data Science”:
Rougier NP, Droettboom M, Bourne PE (2014) Ten Simple Rules for Better Figures. PLoS Comput Biol 10(9): e1003833. read online