This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{# Load necessary libraries} library(dslabs) library(dplyr) library(highcharter)
data(“food_stamps”)
highchart() |>
# it automatically becomes a bubble chart. hc_chart(type = “scatter”) |>
# - x: Year (Time progression) # - y: Costs (Monetary value in $ billions) [cite: 2] # - size: Participants (Volume in millions) [cite: 2] # - color: Participants (Adding a visual gradient for the 3rd variable) hc_add_series( data = food_stamps, type = “scatter”, hcaes(x = year, y = costs, size = participants, color = participants), name = “U.S. Food Stamp Data” ) |>
hc_xAxis(title = list(text = “Fiscal Year”)) |> hc_yAxis(title = list(text = “Total Annual Costs (Billions of USD)”)) |>
# Add a meaningful title and subtitle to describe the analysis hc_title(text = “Evolution of the U.S. Food Stamp Program (SNAP)”) |> hc_subtitle(text = “Visualizing the relationship between participant volume and fiscal costs over time”) |>
hc_credits(enabled = TRUE, text = “Data Source: DS Labs”) |>
hc_add_theme(hc_theme_flat()) |>
hc_colorAxis( stops = color_stops(n = 5, colors = c(“#d4e157”, “#9ccc65”, “#66bb6a”, “#26a69a”, “#004d40”)), title = list(text = “Participants (Millions)”) ) |>
# Configure the interactive tooltip to show detailed data on hover
hc_tooltip( headerFormat = “Year: {point.x}
”, pointFormat =
“Cost: ${point.y}B
Participants: {point.size}M” ) ```