Load the necessary libraries

library(tidyr)
## Warning: package 'tidyr' was built under R version 4.0.2
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(plotly)
## Warning: package 'plotly' was built under R version 4.0.3
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

Used the New Zealand Government Statistical Database to get the data for the population rate.

https://www.stats.govt.nz/large-datasets/csv-files-for-download/

data <- read.csv("bd-dec19-deaths-by-sex-and-age.csv")

# Created my plotly plot to illistrate the number of deaths per year by gender.
graph1 <- plot_ly(data = data, x = ~Period, y = ~Count, color = ~Sex, type = "bar")
graph1 <- graph1 %>% layout(title = "Deaths in New Zealand by Sex", xaxis = list(title = "Year of Death"), yaxis = list(title = "Number of Deaths"))
graph1
## Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
## Please use `arrange()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.