Loading necessary packages and introducting the data set.

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0     ✔ purrr   1.0.1
## ✔ tibble  3.1.8     ✔ dplyr   1.1.0
## ✔ tidyr   1.3.0     ✔ stringr 1.5.0
## ✔ readr   2.1.3     ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library("dslabs")
## Warning: package 'dslabs' was built under R version 4.2.3
library(highcharter)
## Warning: package 'highcharter' was built under R version 4.2.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo 
## Highcharts (www.highcharts.com) is a Highsoft software product which is
## not free for commercial and Governmental use
## 
## Attaching package: 'highcharter'
## 
## The following object is masked from 'package:dslabs':
## 
##     stars
library(RColorBrewer)

data("divorce_margarine") 

Here is the code I used to create my graph.

highchart() %>%
  hc_add_series(data = divorce_margarine,
                   type = "point", hcaes(x = year,
                   y = divorce_rate_maine, 
                   group = margarine_consumption_per_capita)) %>% 
  hc_plotOptions(series = list(marker = list(symbol = "square"))) %>%
  hc_legend(align = "left") %>%
  hc_xAxis(title = list(text= "year")) %>%
  hc_yAxis(title = list(text= "Divorce Rates")) %>%
  hc_title(text= "Amount of Margarine Consumed") %>%
  hc_colors(brewer.pal(10, "RdBu"))

When looking at the possible data options, this data set was the most interesting to me. The first thing I did before creating the graph was to look at the data, which is when I found out this is a very small data set, but I decided to venture through it. I didn’t have to do any cleaning or filtering. I started by identifying the x and y axis and the third variable. Then I customized the graph to have a square symbol. I also added the title and labels. And lastly, I changed the color palette. I do wonder what are the units for the margarine consumption, as in how much margarine is actually being consumed. Although there may not be a correlation between how much margarine is consumed and divorce rates, this graph shows some information that connects the two. One main observation is that as the years go by, margarine consumption and divorce rates decrease. except for a brief period between 2006 and 2008.