if(!require(pacman)) install.packages("pacman")
## Loading required package: pacman
pacman::p_load(leaflet,sp,readr)
library(leaflet)
library(sp)
cardiac<- read_csv("MOCK_DATA.csv")
## Rows: 1000 Columns: 7
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): City, Postcode, Date
## dbl (3): id, Longitude, Latitude
## time (1): Time
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
cardiac$Longitude <- as.numeric(cardiac$Longitude)
cardiac$Latitude <- as.numeric(cardiac$Latitude)
cardiac.SP <- SpatialPointsDataFrame(cardiac[,c(2,3)], cardiac[,-c(2,3)])
bikeicon <- makeIcon(iconUrl = "heart.gif",
iconWidth = 34, iconHeight = 50,
iconAnchorX = 17, iconAnchorY = 48)
leaflet() %>%
addTiles() %>%
addMarkers(data = cardiac,
lng = ~Longitude,
lat = ~Latitude,
icon = bikeicon,
clusterOptions = markerClusterOptions(showCoverageOnHover = FALSE),
popup = ~paste("<b>Address:</b>", cardiac$Address,
"<br /><b>City:</b>", cardiac$City,
"<br /><b>Date (Y/M/D):</b>", cardiac$Date,
"<br /><b>Time (Hr:Min):</b>", cardiac$Time)) %>%
addControl(position = "bottomright",
html = "<p style='width: 235px; font-size:8pt; color:black; margin:0px'>
<b>Author:</b>Anthony Uwandu-uzoma
<br /><b>Data Source:</b> <a href='https://mockaroo.com/'>Mockaroo Portal</a> (2024)
<br />Web portal | All rights reserved</p>") %>%
addLegend(position = "bottomright",
colors = c("#91d467","#ebc83d","#f68f42"),
labels = c("< 10", "< 100", "100+"),
opacity = 1,
title = "Number of cardiac arrest that occurred")
## Warning: Unknown or uninitialised column: `Address`.