Week 5: Make a plot in R

August 3, 2021

Overview: Build on the previous activities by creating plots using external data.

Activity Time Additional Info
Intro to plotting in R 15 min Link to slides
Plotting example 10 min  
Caffeine data walkthrough 5 min  
Group plotting challenge 30 min  

Intro to plotting

Link to slides

Plotting challenge:

1) After signing into OOD, download the coffee data we’ll be working with using the following line: caffeineData <- read.csv("https://raw.githubusercontent.com/DrK-Lo/EvolutionWorkshop/master/assets/caffeine.csv").
2) Inspect the data using the functions head(), tail(), and str().

Your challenge:

  • Create a boxplot to show how the amount of caffeine in a cup of coffee varies by brand.

Hint: Think about which variable (brand or amount of caffeine) should go on which axis!

Bonus plotting challenges:

  • Create a plot to show how the amount of caffeine in a cup of coffee from Starbucks varies by coffee style.

Hint: To filter the dataset for a certain brand, use newDataframeName <- subset(caffeineData, brand == "YourChosenBrand").

  • Create a plot to show how the amount of caffeine in a cup of regular coffee varies by brand.

  • Recreate the first plot, excluding the “decaf” coffee values.