-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinalRegressionExample.R
More file actions
62 lines (48 loc) · 1.21 KB
/
FinalRegressionExample.R
File metadata and controls
62 lines (48 loc) · 1.21 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# FINAL REGRESSION EXAMPLE SCRIPT
# Runs regression for selected gages and creates final comparison table
#
# Source final regression functions
#
source("FinalRegression.R")
#
# Choose regression flow metric
#
# Use "Flow" for cfs
# Use "flow_in_day" for watershed inches/day
regression_flow_col <- "flow_in_day"
#
# Site lookup table
#
site_lookup <- data.frame(
site_no = c("01632000", "01633000", "01634000"),
site = c("Cootes Store", "Mount Jackson", "Strasburg"),
Landseg = c("N51165", "N51171", "N51187")
)
#
# Run all regressions
#
regression_results <- dplyr::bind_rows(
run_one_site_regression("01632000", regression_flow_col = regression_flow_col),
run_one_site_regression("01633000", regression_flow_col = regression_flow_col),
run_one_site_regression("01634000", regression_flow_col = regression_flow_col)
)
#
# Final comparison table
#
final_regression_table <- regression_results %>%
left_join(site_lookup, by = "site_no") %>%
select(site, flow_metric, m, b, Landseg)
print(final_regression_table)
#
# Optional export
#
output_file <- paste0(
"agwrc_regression_coefficients_",
regression_flow_col,
".csv"
)
utils::write.csv(
final_regression_table,
output_file,
row.names = FALSE
)