0

I'm new to R. I've just made a basic interactive choropleth map using the leaflet package in R:

leaflet() %>%
  addProviderTiles("CartoDB.Positron") %>%
  setView(-2, 55, zoom = 5) %>% 
  addPolygons(data = shapes_funding_merge , 
              fillColor = ~pal(shapes_funding_merge$PerPerson), 
              fillOpacity = 0.7, 
              weight = 0.2, 
              smoothFactor = 0.2, 
              popup = ~popup2) %>%
  addLegend(pal = pal, 
            values = shapes_funding_merge$PerPerson, 
            position = "bottomright", 
            title = "Per-head funding (£)")

I want to make this embeddable on a web page. Can I create an embed code that I could send to someone else to embed the leaflet map on their web page?

I hope this isn't a silly question. I've read some other threads but can't seem to find what I think I need.

Any help would be very much appreciated.

Thanks

TL_13
  • 1
  • you want it to be interactive on the website right? did you make this in shiny or just in rmarkdown? can you access the javascript code that is making the leaflet map? – Mike Nov 20 '20 at 14:59
  • You can create an html document of your leaflet map with the htmlwidgets library using htmlwidgets::saveWidget(). – Wawv Nov 20 '20 at 15:14
  • Hi @Mike, thanks for your help. rmarkdown, and Yes i'd like it to be interactive. I'm not sure about accessing accessing the javascript to be honest – TL_13 Nov 20 '20 at 16:52
  • And thanks too @Wawv. I actually tried to install htmlwidgets afte reading about that on anther thread but I couldn't for some reason – TL_13 Nov 20 '20 at 16:53

0 Answers0