# Load the required libraries
library(dslabs)
library(ggplot2)Ds labs dataset
# Load the "temp_carbon" dataset
data("temp_carbon")
# Create a scatterplot with temperature, carbon, and a third variable
ggplot(temp_carbon, aes(x = temp_anomaly, y = carbon_emissions, color = year)) +
geom_point() +
labs(
x = "Temp Anomaly (°C)",
y = "Carbon Emissions (ppm)",
title = "Relationship between Temperature anomaly with carbon emissions throughout the years ",
color = "Year"
) +
scale_color_gradient(low = "blue", high = "red") +
theme_minimal()Warning: Removed 133 rows containing missing values (`geom_point()`).
This visualization helps us see the connection between temperature anomalies, carbon emissions, and time. It shows that as time passes, temperature anomalies have been rising, suggesting a trend of increasing global temperatures. The color-coded scale makes it easy to see these changes over the years.