-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dashboard Code.Rmd
73 lines (64 loc) · 1.94 KB
/
Dashboard Code.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
---
title: "KPMG Map"
author: "Deepak & Shruti"
date: "30 July 2017"
output: html_document
---
```{r}
## Load the library
library(dplyr)
library(maps)
library(reshape2)
library(leaflet)
library(ggplot2)
library(ggmap)
library(gridExtra)
library(htmlwidgets)
library(readr)
#weatherIcon <- makeIcon(
#iconUrl = "./fig/weather.png",
#iconWidth = 30,
#iconHeight = 30
#)
getColor <- function(testDatav2) {
sapply(testDatav2$CreditRating, function(CreditRating) {
if(CreditRating == 5) {
"green"
} else if(CreditRating ==3) {
"orange"
} else {
"red"
} })
}
icons <- awesomeIcons(
icon = 'ios-close',
iconColor = 'black',
library = 'ion',
markerColor = getColor(testDatav2)
)
popupInfo <- paste(testDatav2[['ContractRef']],
", ",
testDatav2[['LoanBalance']],
"<br>",
"Average January Temp in F: ",
testDatav2[['DefaultedLoans']],
"<br>",
"Credit Rating: ",
testDatav2[['CreditRating']],
"<br>",
"LTV: ",
testDatav2[['LTV']],
"<br>",
"Property Value: ",
testDatav2[['PropertyValue']],
sep='')
MapDisplay <- leaflet(testDatav2) %>%
setView(-6.24420, 53.30867, zoom = 12) %>%
addTiles() %>%
addMarkers(testDatav2$AddressLongitude, testDatav2$AddressLatitude, popup= ~ popupInfo,
options = popupOptions(closeButton = TRUE),
clusterOptions = markerClusterOptions(),
icon = icons)
#MapDisplay
saveWidget(MapDisplay, file="Dashboard_Map.html")
```