── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ ggplot2 3.5.1 ✔ tibble 3.2.1
✔ lubridate 1.9.3 ✔ tidyr 1.3.1
✔ purrr 1.0.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(dslabs)library(highcharter)
Registered S3 method overwritten by 'quantmod':
method from
as.zoo.data.frame zoo
Attaching package: 'highcharter'
The following object is masked from 'package:dslabs':
stars
highchart() %>%hc_title(text ="Greenhouse Gas Concentrations Over Time") %>%hc_xAxis(title =list(text ="Year")) %>%hc_yAxis(title =list(text ="Concentration (ppm)")) %>%hc_add_series(data =filter(data_grouped, gas =="CO2"),type ="line",hcaes(x = year, y = concentration),name ="CO₂",color ="yellow" ) %>%hc_add_series(data =filter(data_grouped, gas =="CH4"),type ="line",hcaes(x = year, y = concentration),name ="CH₄",color ="darkcyan" ) %>%hc_add_series(data =filter(data_grouped, gas =="N2O"),type ="line",hcaes(x = year, y = concentration),name ="N₂O",color ="lightcoral" ) %>%hc_tooltip(pointFormat ="Concentration: {point.y} ppm") %>%hc_chart(zoomType ="x")
Project description
In this project I chose to work with the greenhouse_gases dataset from the package dslabs. This dataset provided information regarding the concentration of the main green house gases, C02, CH4, and N20, over the years. In order to create the plot i had to group each gas and arrange it from latest to recent years. Then I utilized highcharter to create an interactive line plot that shows each gas type, each with their respective color shown on the legend, and the concentration level according to the year shown in the x-axis, which can also be zoomed in.