Dslabs Assignment

Author

Dany Drammeh

Brief Introduction

The data set chosen for this visualization is an overview of 7 contagious diseases in the United States. There are 6 variables: disease, count, state, population, year, and weeks_reporting. In all 50 states, there are reports of disease cases spanning from 1928 to 2011. In the example visualization from the notes, the graph focused on one year, however I would like to look at one state with all diseases. Since we are based in the state of Maryland, in my visualization, we will take a look at the change in the number of cases per disease over time in Maryland.

Load the libraries needed

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.2     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.2     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.1     
── 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(RColorBrewer)
library(highcharter)
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
library(ggplot2)
library(dslabs)

Attaching package: 'dslabs'

The following object is masked from 'package:highcharter':

    stars
setwd("C:/Users/danyd/OneDrive/Desktop/data 110/week8hw")

Failed Plot Attempt

Final Plot Visualization

Using a different library and newly discovered highchart() function, I created a more visually appealing line graph by filtering the years through a count of five until 1980. The reason why I stopped at 1980 was because the WHO had declared smallpox “eradicated” meaning the number of cases for smallpox would be extremely low. With that said the selection of years should offer a solid representation of the trend of diseases cases overtime in Maryland.

diseases2 <- us_contagious_diseases |>
  filter(year %in% c(1930, 1935, 1940, 1945, 1950, 1955, 1960, 1965, 1970, 1975, 1980) & state %in% c("Maryland"))

colors <- brewer.pal(7, "Set1")

highchart() |>
  hc_add_series(data = diseases2,
                type="line" , hcaes(x=year,
                                    y=count,
                                    group = disease)) |>
  hc_title(text = "Development of Diseases in Maryland") |>
  hc_xAxis(title = list(text = "Year")) |>
  hc_yAxis(title = list(text = "Total Number of Reported Cases")) |>
  hc_colors(colors) |>
  hc_legend(verticalAlign = "top") |>
  hc_theme(hc_theme_darkunica())
[[1]]

[[2]]
$colors
[1] "#2b908f" "#90ee7e" "#f45b5b" "#7798BF" "#aaeeee" "#ff0066" "#eeaaee"
[8] "#55BF3B"

$chart
$chart$backgroundColor
$chart$backgroundColor$linearGradient
$chart$backgroundColor$linearGradient$x1
[1] 0

$chart$backgroundColor$linearGradient$y1
[1] 0

$chart$backgroundColor$linearGradient$x2
[1] 1

$chart$backgroundColor$linearGradient$y2
[1] 1


$chart$backgroundColor$stops
$chart$backgroundColor$stops[[1]]
$chart$backgroundColor$stops[[1]][[1]]
[1] 0

$chart$backgroundColor$stops[[1]][[2]]
[1] "#2a2a2b"


$chart$backgroundColor$stops[[2]]
$chart$backgroundColor$stops[[2]][[1]]
[1] 1

$chart$backgroundColor$stops[[2]][[2]]
[1] "#3e3e40"




$chart$style
$chart$style$fontFamily
[1] "Unica One, sans-serif"


$chart$plotBorderColor
[1] "#606063"


$title
$title$style
$title$style$color
[1] "#E0E0E3"

$title$style$textTransform
[1] "uppercase"

$title$style$fontSize
[1] "20px"



$subtitle
$subtitle$style
$subtitle$style$color
[1] "#E0E0E3"

$subtitle$style$textTransform
[1] "uppercase"



$xAxis
$xAxis$gridLineColor
[1] "#707073"

$xAxis$labels
$xAxis$labels$style
$xAxis$labels$style$color
[1] "#E0E0E3"



$xAxis$lineColor
[1] "#707073"

$xAxis$minorGridLineColor
[1] "#505053"

$xAxis$tickColor
[1] "#707073"

$xAxis$title
$xAxis$title$style
$xAxis$title$style$color
[1] "#A0A0A3"




$yAxis
$yAxis$gridLineColor
[1] "#707073"

$yAxis$labels
$yAxis$labels$style
$yAxis$labels$style$color
[1] "#E0E0E3"



$yAxis$lineColor
[1] "#707073"

$yAxis$minorGridLineColor
[1] "#505053"

$yAxis$tickColor
[1] "#707073"

$yAxis$tickWidth
[1] 1

$yAxis$title
$yAxis$title$style
$yAxis$title$style$color
[1] "#A0A0A3"




$tooltip
$tooltip$backgroundColor
[1] "rgba(0, 0, 0, 0.85)"

$tooltip$style
$tooltip$style$color
[1] "#F0F0F0"



$plotOptions
$plotOptions$series
$plotOptions$series$dataLabels
$plotOptions$series$dataLabels$color
[1] "#B0B0B3"


$plotOptions$series$marker
$plotOptions$series$marker$lineColor
[1] "#333"



$plotOptions$boxplot
$plotOptions$boxplot$fillColor
[1] "#505053"


$plotOptions$candlestick
$plotOptions$candlestick$lineColor
[1] "white"


$plotOptions$errorbar
$plotOptions$errorbar$color
[1] "white"



$legend
$legend$itemStyle
$legend$itemStyle$color
[1] "#E0E0E3"


$legend$itemHoverStyle
$legend$itemHoverStyle$color
[1] "#FFF"


$legend$itemHiddenStyle
$legend$itemHiddenStyle$color
[1] "#606063"



$credits
$credits$style
$credits$style$color
[1] "#666"



$labels
$labels$style
$labels$style$color
[1] "#707073"



$drilldown
$drilldown$activeAxisLabelStyle
$drilldown$activeAxisLabelStyle$color
[1] "#F0F0F3"


$drilldown$activeDataLabelStyle
$drilldown$activeDataLabelStyle$color
[1] "#F0F0F3"



$navigation
$navigation$buttonOptions
$navigation$buttonOptions$symbolStroke
[1] "#DDDDDD"

$navigation$buttonOptions$theme
$navigation$buttonOptions$theme$fill
[1] "#505053"




$rangeSelector
$rangeSelector$buttonTheme
$rangeSelector$buttonTheme$fill
[1] "#505053"

$rangeSelector$buttonTheme$stroke
[1] "#000000"

$rangeSelector$buttonTheme$style
$rangeSelector$buttonTheme$style$color
[1] "#CCC"


$rangeSelector$buttonTheme$states
$rangeSelector$buttonTheme$states$hover
$rangeSelector$buttonTheme$states$hover$fill
[1] "#707073"

$rangeSelector$buttonTheme$states$hover$stroke
[1] "#000000"

$rangeSelector$buttonTheme$states$hover$style
$rangeSelector$buttonTheme$states$hover$style$color
[1] "white"



$rangeSelector$buttonTheme$states$select
$rangeSelector$buttonTheme$states$select$fill
[1] "#000003"

$rangeSelector$buttonTheme$states$select$stroke
[1] "#000000"

$rangeSelector$buttonTheme$states$select$style
$rangeSelector$buttonTheme$states$select$style$color
[1] "white"





$rangeSelector$inputBoxBorderColor
[1] "#505053"

$rangeSelector$inputStyle
$rangeSelector$inputStyle$backgroundColor
[1] "#333"

$rangeSelector$inputStyle$color
[1] "silver"


$rangeSelector$labelStyle
$rangeSelector$labelStyle$color
[1] "silver"



$navigator
$navigator$handles
$navigator$handles$backgroundColor
[1] "#666"

$navigator$handles$borderColor
[1] "#AAA"


$navigator$outlineColor
[1] "#CCC"

$navigator$maskFill
[1] "rgba(255,255,255,0.1)"

$navigator$series
$navigator$series$color
[1] "#7798BF"

$navigator$series$lineColor
[1] "#A6C7ED"


$navigator$xAxis
$navigator$xAxis$gridLineColor
[1] "#505053"



$scrollbar
$scrollbar$barBackgroundColor
[1] "#808083"

$scrollbar$barBorderColor
[1] "#808083"

$scrollbar$buttonArrowColor
[1] "#CCC"

$scrollbar$buttonBackgroundColor
[1] "#606063"

$scrollbar$buttonBorderColor
[1] "#606063"

$scrollbar$rifleColor
[1] "#FFF"

$scrollbar$trackBackgroundColor
[1] "#404043"

$scrollbar$trackBorderColor
[1] "#404043"


$legendBackgroundColor
[1] "rgba(0, 0, 0, 0.5)"

$background2
[1] "#505053"

$dataLabelsColor
[1] "#B0B0B3"

$textColor
[1] "#C0C0C0"

$contrastTextColor
[1] "#F0F0F3"

$maskColor
[1] "rgba(255,255,255,0.3)"

attr(,"class")
[1] "hc_theme"

attr(,"class")
[1] "hc_theme"

Essay: Like previously stated before, the data set used in this visualization is the us_contagious_diseases data set. Using the variables state, year, and disease, I created a line graph using the highchart function to break down the number of cases for each diseases in a selected year in Maryland. It is a Java styled function that allows users to be more interactive with the graph. Since it is apart of a different library, the commands used to add modifications to the graph are different than the common commands in a ggplot graph. This chart uses hc_ to plot the axis titles and add color to the graph. Instead of looking at a specific year and disease for all 50 states, I wanted to take a look at one state (Maryland) for all diseases to see how the number of reported cases developed over time for each disease. I was intrigued with how readable the highchart was and the interactive ability to look at a point on the line makes me want to continue to utilize highchart for other graphs in the future.