0

I am a new r and leaflet user, and I find that when I run the code for my leaflet map, the map just loads forever. I never get an error. When running the code without trying to color by data, the map takes a good ten minutes to load, but eventually does.

I am having the same issue with knitting.

I haven't had these sort of issues in any of my other work.

Here is the code:

```{r setup, echo = FALSE, warning = FALSE, message = FALSE, 
error = FALSE, cache = TRUE}
knitr::opts_chunk$set(echo = FALSE)

library(leaflet)
library(tidyverse)
library(rgdal)
crime <- read_rds("r_4_tidy.rds")


rf_map <- readOGR(dsn = "/Final_Project/RUS_adm", layer = 
"RUS_adm1")

rf_map <- spTransform(rf_map, CRS("+init=epsg:4326"))

rf_map <- merge(rf_map, crime, by = "ID_1", duplicateGeoms = 
TRUE)

domain <- rf_map@data %>%
 filter(YEAR == "1990") %>%
 select(CRIMESHARE)

coloring <- colorNumeric(palette = "Blues",domain = domain)

rf_map %>%
 leaflet() %>%
 addProviderTiles(provider = "CartoDB") %>%
 addPolygons(weight = 1, 
            #label = NAME,
            color = ~coloring(CRIMESHARE))

Thanks!

loops
  • 29
  • 1
  • 7
  • It's very hard to know without a [reproducible question](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), including a representative sample of data. In the case of working with shapefiles, that might mean just using a commonly available shapefile, such as ones that come with packages folks might have – camille Oct 30 '18 at 14:38
  • Thanks! I think it was a shapefile issue. – loops Nov 01 '18 at 03:01

0 Answers0