Skip to content

Instantly share code, notes, and snippets.

@troyhill
Created December 19, 2018 19:03
Show Gist options
  • Save troyhill/9df3f1fc37946897d73b335413e5f5a7 to your computer and use it in GitHub Desktop.
Save troyhill/9df3f1fc37946897d73b335413e5f5a7 to your computer and use it in GitHub Desktop.
Example download script for Jed
### script to download and summarize DataForEver hydro data for a set of stations
### install.packages("devtools") # install devtools package, if it's not installed already
devtools::install_github("troyhill/SFNRC")
library(SFNRC)
library(plyr)
library(ggplot2)
### stations can be defined manually
stns <- c("S333", "S12D", "S12C", "S332")
dat <- getHydro(stns = stns, data_shape = "wide")
head(dat)
### summarize, e.g., mean annual flow
dd.dat <- ddply(dat, .(stn, year), summarise,
Q = mean(flow, na.rm = TRUE),
Q.se = se(flow))
ggplot(dd.dat, aes(x = year, y = Q)) + theme_classic() + facet_grid(stn ~ .) +
geom_pointrange(aes(ymin = Q - Q.se, ymax = Q + Q.se), size = 0.3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment