DS Labs Assignment

Author

Jeffrey Ren

Load in required libraries and datasets

library(tidyverse)
library("dslabs")
data("temp_carbon")

View and clean up the temp carbon dataset

write_csv(temp_carbon, "temp_carbon.csv", na="")
data1 <- temp_carbon |>
filter(year >= 2000)

Create a multivariable dot plot with three variables of temp, land, and ocean temp anomalies with geom point and connect them with geom line

invisible({
  library(ggplot2)
  dotplot <- ggplot(data1, aes(x = year)) +
    geom_point(aes(y = temp_anomaly, color = "General Temperature Anomaly")) +
    geom_point(aes(y = land_anomaly, color = "Land Temperature Anomaly")) +
    geom_point(aes(y = ocean_anomaly, color = "Ocean Temperature Anomaly")) +
    geom_line(aes(y = temp_anomaly, color = "General Temperature Anomaly")) +
    geom_line(aes(y = land_anomaly, color = "Land Temperature Anomaly")) +
    geom_line(aes(y = ocean_anomaly, color = "Ocean Temperature Anomaly")) +
    labs(title = "Breakdown of Global Temperature Anomalies in Degrees Celsius (2000-2018)",
         x = "Years",
         y = "Temperature Anomalies in Degrees Celsius",
         color = "Anomalies") +
    theme_minimal()
})
dotplot

For this DS Labs assignment I decided to use the temp_carbon dataset from DS Labs. This dataset shows the global temperature anomalies (in degrees celsius) from 1880 to 2018. The different types of temperature anomalies are the ocean, land, and general temperature anomalies. For the graph I wanted to take a look at the relationship between the three over time so I decided to make a dot plot with lines connecting them. I used geom point to create all three variables and then used geom line to connect the dots. I was going to change the colors but the default colors were literally the exact colors I wanted to use for the different variables so I didn’t need to. I then changed used labs to create the axis’, title, and legend. Finally I added finishing touches by changing the theme to minimal.