@@ -23,7 +23,7 @@ USGS <- USGS %>%
23
23
rename(discharge_cfs = X_00060_00003 )
24
24
WWPark <- USGS [3 : 4 ] # Collect only date & discharge
25
25
26
- # # //
26
+
27
27
# Get years in quartiles to use as reference
28
28
annual <- WWPark %> %
29
29
mutate(year = year(Date )) %> %
@@ -39,9 +39,8 @@ avg_annual <- avg_annual %>%
39
39
group_by(day_of_year ) %> %
40
40
summarize(avg_discharge = mean(discharge_cfs ))
41
41
42
- # # \\
43
42
44
- # # // Collect years and convert date into day of year
43
+ # # Collect years and convert date into day of year
45
44
# Wet
46
45
wet <- WWPark %> %
47
46
mutate(year = year(Date )) %> %
@@ -109,7 +108,7 @@ dry_months <- dry %>%
109
108
mutate(month = month(Date )) %> %
110
109
group_by(month ) %> %
111
110
summarize(avg_discharge = mean(discharge_cfs ))
112
- # \\
111
+
113
112
114
113
# ## FEIS table into R -------------------------------------------------------
115
114
@@ -266,7 +265,7 @@ postnisp_avg_annual <- sumpostnisp(C_avg_annual)
266
265
267
266
threshold <- 355 # Collected from economic survey data
268
267
269
- # Historical
268
+ # # Historical
270
269
historicalbday <- function (frame ){
271
270
frame <- frame [which(frame $ discharge_cfs > = threshold ),]
272
271
frame <- frame %> %
@@ -276,6 +275,7 @@ historicalbday <- function(frame){
276
275
summarize(boatabledays = sum(logic ))
277
276
}
278
277
278
+ # Find boatable days for each year, and year type
279
279
hist_bdays <- historicalbday(WWPark )
280
280
281
281
wet_hist_bdays <- historicalbday(wet )
@@ -284,7 +284,7 @@ dryTypical_hist_bdays <- historicalbday(dryTypical)
284
284
dry_hist_bdays <- historicalbday(dry )
285
285
286
286
287
- # Post-NISP
287
+ # # Post-NISP
288
288
postnispbday <- function (frame ){
289
289
frame <- frame [which(frame $ avgdischarge_nisp > = threshold ),]
290
290
frame <- frame %> %
@@ -294,14 +294,16 @@ postnispbday <- function(frame){
294
294
summarize(postnisp_boatabledays = sum(logic ))
295
295
}
296
296
297
+ # Find boatable days for each year, and year type
297
298
postnisp_bdays <- postnispbday(C_avg_annual )
298
299
299
300
wet_postnisp_bdays <- postnispbday(C_wet )
300
301
wetTypical_postnisp_bdays <- postnispbday(C_wetTypical )
301
302
dryTypical_postnisp_bdays <- postnispbday(C_dryTypical )
302
303
dry_postnisp_bdays <- postnispbday(C_dry )
303
304
304
- # Count loss in days in column 'aloss'
305
+
306
+ # Count loss in days in column 'aloss' using the overall historical bdays data
305
307
count <- left_join(hist_bdays , postnisp_bdays , by = " year" )
306
308
count [is.na(count )] <- 0 # Make N/A values = 0
307
309
count <- count %> %
@@ -315,6 +317,7 @@ dfcount <- count %>%
315
317
316
318
# Plots -------------------------------------------------------------------
317
319
320
+ # # Plots for each year type
318
321
plotwet <- ggplot(wet_annual , aes(x = day_of_year , y = avg_discharge )) + geom_line(color = " skyblue2" ) +
319
322
geom_line(data = postnisp_wet , aes(x = day_of_year , y = avg_discharge ), color = " slategray" ) +
320
323
scale_y_continuous(breaks = seq(0 , 2500 , 500 ), lim = c(0 , 2500 )) +
@@ -346,15 +349,15 @@ plotavgannual <- ggplot(avg_annual, aes(x = day_of_year, y = avg_discharge)) + g
346
349
scale_x_continuous(breaks = c(1 ,61 ,122 ,183 ,245 ,306 ),
347
350
labels = c(" Jan" , " Mar" , " May" , " Jul" , " Sep" , " Nov" )) # Get every other month
348
351
349
-
352
+ # Figure with all 5 graphs
350
353
figure <- ggarrange(plotwet , plotwettyp , plotdry , plotdrytyp ,plotavgannual ,
351
354
labels = c(" wet" , " wet typical" , " dry" , " dry typical" , " averaged annual" ),
352
355
ncol = 2 , nrow = 3 )
353
- print(figure )
354
356
357
+ print(figure )
355
358
356
359
357
- # Plot historical boatable days
360
+ # # Plot historical boatable days
358
361
plothist_bdays <- ggplot (data = hist_bdays , aes(x = year , y = boatabledays )) +
359
362
geom_bar(stat = " identity" , fill = " skyblue2" ) +
360
363
scale_y_continuous(breaks = seq(0 , 120 , 20 ), lim = c(0 , 120 )) +
@@ -363,8 +366,7 @@ plothist_bdays <- ggplot (data = hist_bdays, aes(x = year, y = boatabledays)) +
363
366
print(plothist_bdays )
364
367
365
368
366
-
367
- # Plot change in boatable days
369
+ # # Plot change in boatable days
368
370
changeinbdays <- ggplot(data = dfcount , aes(x = year , y = boatabledays , fill = impact )) +
369
371
geom_bar(stat = " identity" , position = " stack" ) +
370
372
scale_fill_manual(values = c(" tomato2" , " slategray" ),
0 commit comments