Data Source: The data source I used for this assignment is data from the Actuary Climate Index. I specifically wanted to look at the final sea level change for each region.

For the table I wanted to convey the final change in sea level over the last 60 years for each North American Region. I did this by filtering to the final sea level in my data file.

For Functionality, I added the Hover option. I did this to make it easier to read the column, and to select the right column. I did this since the table is so long, and difficult to read. I wanted to add a trend for the change over 60 years, however I could not get my code to work, so I removed it.

For Formatting I increased the font to 18, I also centered the data in the columns. I also added a title above the whole table. I used the KBLe function since I liked the look of this table best.

#Bringing in data from the Actuaries Climate Index
library(ggplot2)
## Warning in register(): Can't find generic `scale_type` in package ggplot2 to
## register S3 method.
library(reshape2)
## Warning: package 'reshape2' was built under R version 4.1.3
library(plotly)
## Warning: package 'plotly' was built under R version 4.1.3
## 
## 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
library(htmlwidgets)
## Warning: package 'htmlwidgets' was built under R version 4.1.3
library(knitr)
library(tidyr)
## 
## Attaching package: 'tidyr'
## The following object is masked from 'package:reshape2':
## 
##     smiths
library(kableExtra)
## Warning: package 'kableExtra' was built under R version 4.1.3
SL <- readxl::read_excel("C:/Users/14252/Desktop/ACI_JDB.xlsx",sheet = 2)
SL$time <-paste(SL$Year,"-",SL$Month,"-01")

#change to long format
SL <- melt(SL, id.vars= c("time","Year", "Month"))
#SL
#change time from character to date
SL$time <- as.Date(SL$time, format = "%Y - %m -%d")
# limit to most recent day
SL2 <- SL %>% 
  filter(time == max(time)) %>%
  drop_na()


SL3 <- SL2 %>%
  select(time, variable, value) %>%
  kbl(col.names = c("Date",
                    "Region",
                    "mm change from origin"),
  align = c("c", "c", "c")) %>%
  kable_styling(font_size = 18) %>%
  add_header_above(c("Summary of Sea level Change by Region" = 3)) %>%
  kable_paper(lightable_options = "hover", full_width = FALSE)
SL3
Summary of Sea level Change by Region
Date Region mm change from origin
2022-02-01 ALA -4.47
2022-02-01 CEA 4.31
2022-02-01 CWP 0.65
2022-02-01 NEA 3.27
2022-02-01 NEF 0.70
2022-02-01 NPL -2.01
2022-02-01 NWP 0.22
2022-02-01 SEA 4.09
2022-02-01 SPL 4.09
2022-02-01 SWP 1.60
2022-02-01 CAN 0.44
2022-02-01 USA 3.18
2022-02-01 USC 2.44