knitr::opts_chunk$set(echo = TRUE)
suppressPackageStartupMessages(library(dplyr)) suppressPackageStartupMessages(library(tidyr)) suppressPackageStartupMessages(library(readr)) suppressPackageStartupMessages(library(readxl)) suppressPackageStartupMessages(library(here)) suppressPackageStartupMessages(library(janitor)) suppressPackageStartupMessages(library(lubridate)) nswgov <- read_csv(here::here("data", "nswgov_daily.csv")) %>% clean_names() nswgov$date <- dmy(nswgov$date) nswgov_long <- nswgov %>% select(1:27) %>% gather(key = "site", value = "aqi", 2:27) nswgov_long$site <- gsub("_raqi_24_hour_index","",nswgov_long$site) nswgov_long$site <- gsub("_"," ",nswgov_long$site) nswgov_long$site <- stringr::str_to_title(nswgov_long$site, locale = "en") regions <- distinct(nswgov_long, site) nswgov_long <- nswgov_long%>% mutate(level = case_when( aqi %in% c(0:33) ~ "Very Good", aqi %in% c(34:66) ~ "Good", aqi %in% c(67:99) ~ "Fair", aqi %in% c(100:149) ~ "Poor", aqi %in% c(150:200) ~ "Very Poor", aqi %in% c(201:max(aqi,na.rm=T)) ~ "Hazardous" )) todaydate <- today() yesterdaydate <- today()-2
```r
selectInput('var', label = 'Is it smoky in:', choices = regions) textOutput("selected_var")
yesterdaydata <- reactive({nswgov_long%>% filter(date == yesterdaydate, site == input$var) })
renderText({ paste("You have selected", input$var, "the AQI yesterday was", yesterdaydata()$aqi) }) renderText({ paste("The air quality was", yesterdaydata()$level) })
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.