Created
September 27, 2018 13:54
-
-
Save troyhill/48b59bf3ef4a972a627b5de6444053c3 to your computer and use it in GitHub Desktop.
Script to plot water levels at S-333 and NP206
This file contains hidden or 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 plot water levels at S-333 and NP206 | |
### | |
stg <- read.csv("/data_S333_NP206_20180927.csv") | |
plot(stg$stg.NP206 ~ stg$hw.S333, pch = 19, cex = 0.5, las = 1, xlab = "Stage at S-333 (headwater; ft NGVD29)", ylab = "Stage at NP206 (ft NGVD29)", col = "darkgray") | |
abline(lm1 <- lm(stg$stg.NP206 ~ stg$hw.S333), col = "blue", lty = 1) | |
### estimate stage at NP206 corresponding to Walker's "low trigger" at S-333 | |
low.trigger <- 8.75 | |
NP206.stg <- low.trigger * coefficients(lm1)[2] + coefficients(lm1)[1] | |
lines(x = c(low.trigger, low.trigger, 0), y = c(-5, NP206.stg, NP206.stg), col = "blue", lty = 2) | |
### add red line showing NP-206 marsh surface elevation (5.99' NGVD29) | |
abline(h = 5.99, col = "red", lty = 2) | |
Nice, thanks! I didn't realize predict had a confidence interval option. Very useful.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @troyhill for sharing your code...its refreshing to see someone else using R ;)
For efficiency, you can use the predict function in base R to get the NP206 stage value for the S333 HW "low trigger" based on the linear model that you applied. Also you can get fancy and include confidence intervals.