-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStreamflow_Parse.Rmd
42 lines (36 loc) · 1.29 KB
/
Streamflow_Parse.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
title: "R Notebook"
output: html_notebook
---
```{r}
setwd("/Users/nicholasdepsky/Dropbox/Berkeley_tings/Spring 2018/ER 290A/ER290A-finalproject")
df <- read.csv("NYuba_GoodYears_CFS_raw.csv", check.names = F)
library(lubridate)
library(dplyr)
library(ggplot2)
library(magrittr)
date_fix <- function(x, year=1950){
d <- mdy(x)
m <- year(d) %% 100
year(d) <- ifelse(m > year %% 100, 1900+m, 2000+m)
as.Date(d)
}
df$Day <- date_fix(df$Day)
day_df <- aggregate(CFS ~ Day, df, mean) %>% set_colnames(c("Date", "CFS"))
day_df$CMS <- day_df$CFS*0.028316847
day_df$CFS <- NULL
#day_df <- read.csv("NYuba_Inflow_Day.csv", check.names = F)
#day_df$Date <- date_fix(day_df$Date)
month_df <- day_df %>% mutate(ymd = paste(month(Date),"01",year(Date),sep = "/"))
month_df$ymd <- date_fix(month_df$ymd)
month_df <- aggregate(CMS ~ ymd, month_df, mean) %>% set_colnames(c("Date", "CMS"))
#month_df$CMS <- month_df$CMS*0.7
write.csv(day_df, file = "NYuba_Inflow_Day.csv", row.names = F)
write.csv(month_df, file = "NYuba_Inflow_Month.csv", row.names = F)
```
```{r}
ggplot(day_df, aes(x = Day, y = CFS)) + geom_line() + ggtitle("Daily Average Streamflow [CFS]") + labs(x = "Date")
```
```{r}
ggplot(month_df, aes(x = ymd, y = CFS)) + geom_line() + ggtitle("Monthly Average Streamflow [CFS]") + labs(x = "Date")
```