Goldstream Creek Temperature

The following plot shows the daily minimum and maximum temperature for the Goldstream Creek (DW1454) weather station October 2009 to the present. Use the selector on the bottom to adjust the range of the plot. Moving the cursor into the plot area will show you the data for the date your cursor is over.


The plot is generated daily, using the following code:

library(tidyverse)
library(lubridate)
library(zoo)
library(dygraphs)
# latest versions:
# devtools::install_github(c("ramnathv/htmlwidgets", "rstudio/dygraphs"))

dw1454 <- src_postgres(host="localhost")

west <- tbl(dw1454, build_sql("SELECT * FROM arduino_west",
                              con = dw1454)) %>%
  filter(!is.na(wtemp), wtemp < 100) %>%
  mutate(date = date(obs_dt),
         wtemp = round(wtemp, 1L))

west_daily <- west %>%
  group_by(date) %>%
  summarize(tmin = min(wtemp), tmax = max(wtemp)) %>%
  collect(n = Inf)

west_dy_min <- zoo(x = west_daily$tmin, order.by = west_daily$date)
west_dy_max <- zoo(x = west_daily$tmax, order.by = west_daily$date)
west_dy_zoo <- cbind(west_dy_max, west_dy_min)

last_year_str <- as.character(max(west_daily$date) - years(1))
dygraph(west_dy_zoo,
        main = "Daily Temperatures, Goldstream Creek (DW1454)") %>%
  dyAxis("y", label = "Temperature (°F)") %>%
  dySeries("west_dy_min", label = "Min temp (°F)", color = "darkcyan") %>%
  dySeries("west_dy_max", label = "Max temp (°F)", color = "darkred") %>%
  dyLegend(show = "always", width = 400) %>%
  dyRangeSelector(dateWindow = c(last_year_str, as.character(max(west_daily$date)))) %>%
  dyOptions(gridLineColor = "lightgrey")