Created
December 19, 2018 19:03
-
-
Save troyhill/9df3f1fc37946897d73b335413e5f5a7 to your computer and use it in GitHub Desktop.
Example download script for Jed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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