library(leaflet)
dat <- read.csv("../Desktop/2021-05-metropolitan-street.csv")
str(dat)
## 'data.frame': 92225 obs. of 12 variables:
## $ Crime.ID : chr "38c135d1f9183c468bab40d636ab2637b0d00b8d4ef6a35c3324aab3fe4d9a91" "38c135d1f9183c468bab40d636ab2637b0d00b8d4ef6a35c3324aab3fe4d9a91" "525a8e1af105dcf083faa386e4f4cef63bc0c6b0a8c39b741cd9c0d76e2d993e" "925441c6a0ccca169eeef3bb5aa2f0d9f0f7308669913aeb6837da5e48fb322f" ...
## $ Month : chr "2021-05" "2021-05" "2021-05" "2021-05" ...
## $ Reported.by : chr "Metropolitan Police Service" "Metropolitan Police Service" "Metropolitan Police Service" "Metropolitan Police Service" ...
## $ Falls.within : chr "Metropolitan Police Service" "Metropolitan Police Service" "Metropolitan Police Service" "Metropolitan Police Service" ...
## $ Longitude : num -0.664 -0.664 -1.258 0.902 -0.812 ...
## $ Latitude : num 50.8 50.8 53.1 51.1 51.8 ...
## $ Location : chr "On or near Brooks Lane" "On or near Brooks Lane" "On or near Park Street" "On or near Waltham Close" ...
## $ LSOA.code : chr "E01031433" "E01031433" "E01027967" "E01024004" ...
## $ LSOA.name : chr "Arun 014B" "Arun 014B" "Ashfield 004A" "Ashford 006E" ...
## $ Crime.type : chr "Violence and sexual offences" "Violence and sexual offences" "Violence and sexual offences" "Violence and sexual offences" ...
## $ Last.outcome.category: chr "Under investigation" "Under investigation" "Under investigation" "Under investigation" ...
## $ Context : logi NA NA NA NA NA NA ...
dat <- dat[!is.na(dat$Longitude)&!is.na(dat$Latitude),]
library(leaflet)
dat %>%
leaflet() %>%
addTiles() %>%
addMarkers(popup=dat$Crime.type , clusterOptions=markerClusterOptions())
## Assuming "Longitude" and "Latitude" are longitude and latitude, respectively