-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
237 lines (186 loc) · 7.06 KB
/
index.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
---
title: "Brandon Road Interbasin Project Risk Analysis Report"
author: "USACE Rock Island District"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: book
description: "Report description goes here."
bibliography: [book.bib, packages.bib]
biblio-style: apalike
csl: chicago-fullnote-bibliography.csl
---
# Introduction {-}
## Project
* P2 project name: Brandon Rd-Great Lakes/Miss Rvr Interbasin
* P2 project number: 482782
* P2 program code: 451617
## Architecture
This report using the following architecture:
* **Data Entry** - An [Oracle APEX](https://apex.oracle.com/) web-database application stores the risk analysis data and allows project risk managers to enter and edit the data. This application resides on the USACE intranet (CorpsNet) and is only available for editing to project risk managers.
* **Reporting** - This report is produced using [R]()
* **Code Repository** -
* **Static Website Publishing** -
* **Project Viewer** -
```{r, echo=FALSE, warning=FALSE, message=FALSE, out.width="100%", fig.cap="Report Architecture"}
knitr::include_graphics(path = "diagrams/cloud_arch-workflow.drawio.svg")
```
<!-- Libraries -->
```{r library, include=FALSE}
library(tidyverse)
library(knitr)
library(rmarkdown)
library(rlang)
library(lubridate)
library(DBI)
library(ROracle)
library(keyring)
library(tools)
library(kableExtra)
library(pander)
library(timevis)
library(treemapify)
library(gridExtra)
library(formattable)
library(igraph)
library(edgebundleR)
library(downloadthis)
library(rarr)
```
```{r source, include=FALSE}
#source("R/risk_register_table.R")
#source("R/decision_register_table.R")
#source("R/action_register_table.R")
#source("R/atx_header.R")
#source("R/pandoc_header.R")
#source("R/percent_treemap.R")
#source("R/timeline.R")
#source("R/format_id.R")
#source("R/id_link.R")
#source("R/eng_level_history.R")
#source("R/discussion_table.R")
#source("R/related_block_table.R")
#source("R/remove_test_records.R")
#source("R/impact_outcome_table.R")
#source("R/risk_pies.R")
```
<!-- Report Constants -->
```{r, include=FALSE}
qa_email_address <- "[email protected]"
current_date <- lubridate::today()
```
```{r, include=FALSE}
# Use the `keyring` package to save the database username and password in the
# system credential store
key_service <- "egis-db-brandonroad"
user_name <- "BrandonRoad"
# Set once on each computer prior to building book
#keyring::key_set(service = key_service, username = user_name)
# Make Oracle connection
drv <- DBI::dbDriver("Oracle")
host <- "egis-db"
port <- "1521"
sid <- "B5SDEDP1"
connect_string <- paste0(
"(DESCRIPTION=",
"(ADDRESS=(PROTOCOL=tcp)(HOST=", host, ")(PORT=", port, "))",
"(CONNECT_DATA=(SID=", sid, ")))")
con_roracle <- ROracle::dbConnect(drv,
username = user_name,
password = keyring::key_get(key_service,
user_name),
dbname = connect_string)
```
```{r, include=FALSE}
# Import tables from Oracle
risk_oracle <- ROracle::dbReadTable(con_roracle,
"RISK_MAIN_VIEW")
events_oracle <- ROracle::dbReadTable(con_roracle,
"EVENTS_MAIN_VIEW")
discussion_oracle <- ROracle::dbReadTable(con_roracle,
"DISCUSSION_LOG_MAIN_VIEW")
action_oracle <- ROracle::dbReadTable(con_roracle,
"ACTION_MAIN_VIEW")
decision_oracle <- ROracle::dbReadTable(con_roracle,
"DECISION_MAIN_VIEW")
rel_action_action_oracle <- ROracle::dbReadTable(con_roracle,
"REL_ACTION_ACTION_MAIN_VIEW")
rel_dec_dec_oracle <- ROracle::dbReadTable(con_roracle,
"REL_DEC_DEC_MAIN_VIEW")
rel_dec_action_oracle <- ROracle::dbReadTable(con_roracle,
"REL_DEC_ACTION_MAIN_VIEW")
rel_risk_action_oracle <- ROracle::dbReadTable(con_roracle,
"REL_RISK_ACTION_MAIN_VIEW")
rel_risk_dec_oracle <- ROracle::dbReadTable(con_roracle,
"REL_RISK_DEC_MAIN_VIEW")
rel_risk_risk_oracle <- ROracle::dbReadTable(con_roracle,
"REL_RISK_RISK_MAIN_VIEW")
# Disconnect from the database
ROracle::dbDisconnect(con_roracle)
```
<!-- Wrangle Risk/Action/Decision Data -->
```{r wrangle-risk, include=FALSE}
risk<-rarr::wrangle_risk(risk_oracle)
```
```{r write-risk, include=FALSE}
risk %>%
select(!c(OBJECTID, risk_no_link)) %>%
write_csv(file = "download/risk.csv", quote = "all")
```
```{r wrangle-events, include=FALSE}
events<-rarr::wrangle_events(events_oracle)
```
```{r wrangle-discussion, include=FALSE}
discussion<-rarr::wrangle_discussion(discussion_oracle)
```
```{r wrangle-action, include=FALSE}
action<-rarr::wrangle_action(action_oracle)
```
```{r wrangle-decision, include=FALSE}
decision<-rarr::wrangle_decision(decision_oracle)
```
<!-- Wrangle Related Items -->
```{r wrangle-rel-action-action, include=FALSE}
rel_action_action<-rarr::wrangle_rel_action_action(rel_action_action_oracle)
```
```{r wrangle-rel-dec-action, include=FALSE}
rel_dec_action <- rarr::wrangle_rel_dec_action(rel_dec_action_oracle)
```
```{r wrangle-rel-dec-dec, include=FALSE}
rel_dec_dec<- rarr::wrangle_rel_dec_dec(rel_dec_dec_oracle)
```
```{r wrangle-rel-risk-action, include=FALSE}
rel_risk_action<-rarr::wrangle_rel_risk_action(rel_risk_action_oracle)
```
```{r wrangle-rel-risk-dec, include=FALSE}
rel_risk_dec<- rarr::wrangle_rel_risk_dec(rel_risk_dec_oracle)
```
```{r wrangle-rel-risk-risk, include=FALSE}
rel_risk_risk<-rarr::wrangle_rel_risk_risk(rel_risk_risk_oracle)
```
<!-- Create Timelines -->
```{r create_timevis_df, include=FALSE}
# Create a timevis "data" data frame of risks
risk_time <- rarr::wrangle_risk_time(risk)
# Create a timevis "group" data frame to group risks by unique Risk Categories
risk_time_riskcategory <- rarr::wrangle_risk_time_riskcat(risk)
```
```{r create-items, include=FALSE}
# Create a df of all items (risks, actions, decisions)
items <- rarr::create_items(risk, action, decision)
```
```{r create-relations, include=FALSE}
# Create a df of all relationships
relations<-rarr::create_relations(rel_action_action, rel_dec_action, rel_dec_dec, rel_risk_action,rel_risk_dec,rel_risk_risk)
```
```{r network-analysis, include=FALSE}
# Create the igraph object for network analysis
relate_igraph <- igraph::graph_from_data_frame(d = relations,
vertices = items,
directed = FALSE)
related_blocks<-rarr::network_analysis(relate_igraph, items)
```
```{r dendrogram, include=FALSE}
# Create dendrogram
eb <- cluster_edge_betweenness(relate_igraph)
#plot_dendrogram(eb)
```