library(data.table)
## Warning: package 'data.table' was built under R version 3.3.2
dat <- fread("C:/Users/Kajal/Downloads/datafestdata2017_tiny.csv")
##
Read 0.0% of 1000000 rows
Read 20.0% of 1000000 rows
Read 36.0% of 1000000 rows
Read 52.0% of 1000000 rows
Read 74.0% of 1000000 rows
Read 1000000 rows and 28 (of 28) columns from 0.214 GB file in 00:00:17
dat$user_location_latitude <- as.numeric(dat$user_location_latitude) #they won't import as numeric
## Warning: NAs introduced by coercion
dat$user_location_longitude <- as.numeric(dat$user_location_longitude)
## Warning: NAs introduced by coercion
dat$is_booking <- as.factor(dat$is_booking)
dat_small <- dat[1:100000,]
dat_small_book <- dat_small[which(is_booking==1),]
dat_small_no_book <- dat_small[which(is_booking==0),]
library(leaflet)
## Warning: package 'leaflet' was built under R version 3.3.3
library(maps)
## Warning: package 'maps' was built under R version 3.3.3
leaflet()
map.US <- map(database="state", fill = TRUE)

#cluster
leaflet(data=map.US) %>% addTiles() %>% addPolygons(fillColor = topo.colors(10, alpha = NULL), stroke = FALSE) %>%
addMarkers(dat_small_book$user_location_longitude, dat_small_book$user_location_latitude, clusterOptions = markerClusterOptions(), group="Book") %>%
addMarkers(dat_small_no_book$user_location_longitude, dat_small_no_book$user_location_latitude, clusterOptions = markerClusterOptions(), group="Look") %>%
addLayersControl(overlayGroups = c("Book","Look") ,options = layersControlOptions(collapsed = FALSE))
## Warning in validateCoords(lng, lat, funcName): Data contains 1771 rows with
## either missing or invalid lat/lon values and will be ignored
## Warning in validateCoords(lng, lat, funcName): Data contains 19055 rows
## with either missing or invalid lat/lon values and will be ignored