-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemplate_individual_html.Rmd
177 lines (127 loc) · 6.43 KB
/
template_individual_html.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
---
title: "Disaster Survey Sheet"
output:
html_document:
toc: true
toc_depth: 3
---
```{r setup, echo=FALSE, warning=FALSE, message=FALSE}
library(dplyr)
library(lubridate)
library(jsonlite)
library(knitr)
library(ggplot2)
library(leaflet)
knitr::opts_chunk$set(echo=FALSE, warning=FALSE, message=FALSE)
options (scipen=4)
cbPalette <- c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7", "#999999", "#000000", "#8856a7")
###### FOR TESTING #####
#field_data <- read.csv("MOCK_DATA.csv", header=TRUE, sep=",")
#report_id <- 33
#`r disastername`,
report_id <- locationid
```
*Report Date: `r Sys.Date()`*
### Property Information
**Name:** `r field_data$name_property_owner[id=report_id]`
**Address:** `r field_data$street_address[id=report_id]`
**Municipality:** `r field_data$city[id=report_id]`
**Zip Code:** `r field_data$zip_code[id=report_id]`
**County:** `r field_data$county[id=report_id]`
**Phone:** `r field_data$phone_number[id=report_id]`
**Type of Applicant or Structure:** `r field_data$property_type[id=report_id]`
**Homeowner or Renter:** `r field_data$owner_type[id=report_id]`
### Insurance Information
**Insurance Agent Name:** `r field_data$name_insurance[id=report_id]`
**Insurance Agent Phone:** `r field_data$phone_insurance[id=report_id]`
**Flood Insurance:** `r field_data$flood_insurance[id=report_id]`
### Estimated Disaster Loss Details
```{r loss_table, echo=FALSE, warning=FALSE, message=FALSE}
# row for each of structure, contents, land and improvements
# bring in variables for market value, amount damaged by disaster, amount covered by insurance
structure <- data.frame("Structure", field_data$marketvalue_structure[id=report_id],
field_data$disaster_structure[id=report_id],
field_data$insurance_structure[id=report_id])
colnames(structure) <- c("Area", "MarketValue", "DisasterLoss", "InsuranceCovered")
contents <- data.frame("Contents", field_data$marketvalue_contents[id=report_id],
field_data$disaster_contents[id=report_id],
field_data$insurance_contents[id=report_id])
colnames(contents) <- c("Area", "MarketValue", "DisasterLoss", "InsuranceCovered")
landimprov <- data.frame("Land & Improvements", field_data$marketvalue_land[id=report_id],
field_data$disaster_land[id=report_id],
field_data$insurance_land[id=report_id])
colnames(landimprov) <- c("Area", "MarketValue", "DisasterLoss", "InsuranceCovered")
# bind these
loss_table <- rbind(structure, contents, landimprov)
# calculate amount and percent of uninsured loss
loss_table$UninsuredLoss <- loss_table$DisasterLoss - loss_table$InsuranceCovered
loss_table$UninsuredLossPercent <- paste(round(loss_table$UninsuredLoss / loss_table$MarketValue*100, 2), "%")
kable(loss_table, col.names = c("Area", "Market Value", "Disaster Loss", "Covered by Insurance",
"Uninsured Loss", "Uninsured Loss %"),
align=c(rep("r", 6)), row.names = F, format.args=list(big.mark = ','))
```
### Building Damage
**Damage Category:** `r field_data$damage_category[id=report_id]`
```{r damage_bysystem, echo=FALSE, warning=FALSE, message=FALSE}
foundation <- data.frame("Foundation", field_data$damage_foundation[id=report_id])
colnames(foundation) <- c("Area", "PercentDamange")
floor <- data.frame("Floor", field_data$damage_floor[id=report_id])
colnames(floor) <- c("Area", "PercentDamange")
exterior <- data.frame("Exterior Walls", field_data$damage_exterior[id=report_id])
colnames(exterior) <- c("Area", "PercentDamange")
#roof <- data.frame("Roof", field_data$damage_roof[id=report_id])
#colnames(roof) <- c("Area", "PercentDamange")
interior <- data.frame("Interior Walls", field_data$damage_interior[id=report_id])
colnames(interior) <- c("Area", "PercentDamange")
plumbing <- data.frame("Plumbing", field_data$damage_plumbing[id=report_id])
colnames(plumbing) <- c("Area", "PercentDamange")
heat_ac <- data.frame("Heating / AC", field_data$damage_hvac[id=report_id])
colnames(heat_ac) <- c("Area", "PercentDamange")
electrical <- data.frame("Electrical", field_data$damage_electrical[id=report_id])
colnames(electrical) <- c("Area", "PercentDamange")
systemdamage <- rbind(foundation, floor, exterior, interior, plumbing, heat_ac, electrical)
colnames(systemdamage) <- c("SystemArea", "PercentDamange")
kable(systemdamage, col.names = c("System Area", "Percent Damaged"), row.names=F)
# thoughts on section of report
# Estimated Replacement Cost looks like sum of percent damanged times fair market value of property
# which is loss_table$MarketValue
```
**Total % Damaged:** `r round(sum(systemdamage$PercentDamange),0)`%
**Estimated Replacement Cost:** $ `r format((sum(systemdamage$PercentDamange * sum(loss_table$MarketValue))), big.mark = ",")`
**Estimated Damage to Contents:** $ `r format(sum(loss_table$DisasterLoss[loss_table$Area=="Contents"]), big.mark=",")`
**Total Estimated Damange:** $ `r format((sum(systemdamage$PercentDamange * sum(loss_table$MarketValue)) + sum(loss_table$DisasterLoss[loss_table$Area=="Contents"])), big.mark=",")`
### Comments
`r field_data$comments[id=report_id]`
### Assessor
**Name of Assessor:** `r field_data$name_of_assessor[id=report_id]`
**Date:** `r field_data$date[id=report_id]`
### Photos
```{r photo1, out.width = "400px"}
knitr::include_graphics("photos/cevisit.jpg")
```
```{r photo2, out.width = "400px"}
knitr::include_graphics("photos/ceVisit5.jpg")
```
```{r map}
# map.data <- filter(muni.data, !is.na(Violation), !is.na(lat))
# leaflet() %>%
# # use the CartoDB map for more subdued map tile colors
# addProviderTiles("CartoDB.Positron") %>%
# setView(lng = -79.8, lat = 40.4212, zoom = 12) %>%
# addCircleMarkers(data = map.data,
# lng = ~long, lat = ~lat,
# popup = paste("Violation:", map.data$Violation,
# "<br> Initial Date:", map.data$EventDate),
# # the marker clusters gives us a nice visual
# # effect where when we zoom out points cluster
# # together, and as we zoom in they are pulled apart
# # showing the individual markers.
# #clusterOptions = markerClusterOptions()
# radius = 5,
# stroke = TRUE,
# color = "#323232",
# weight = 3,
# fillColor = "#7fcdbb",
# fillOpacity = 0.7
# )
```