Saving leaflet output as html
Open a new RMarkdown document. When you are using RStudio go to File -> New File -> R Markdown
.
Once you saved the file, you can insert your code into a chunk, like this:
---
title: "Leaflet Map"
output: html_document
---
```{r}
library(leaflet)
rand_lng = function(n = 10) rnorm(n, -93.65, .01)
rand_lat = function(n = 10) rnorm(n, 42.0285, .01)
m = leaflet() %>% addTiles() %>% addCircles(rand_lng(50), rand_lat(50), radius = runif(50, 10, 200))
m
```
Then Press the Knit HTML
Button above the code window and your application will open in a new HTML file. You can send the file via eMail or upload it to your ftp.
Something like:
library(htmlwidgets)
saveWidget(m, file="m.html")
seems to work on most widgets.
I have faced the same problem and after installing Github version the problem was fixed.
# Or Github version
if (!require('devtools')) install.packages('devtools')
devtools::install_github('rstudio/leaflet')
My present version is 1.1.0.9000, running on macOS Sierra, RStudio Version 1.1.232 and R 3.4.0
You can export from RStudio or save using htmlwidgets.