Let\'s say I have a code like this
# Install devtools if needed
if(!require(devtools)) install.packages(\"devtools\")
# view rawif-devtools.R hosted with ❤ b
I developed a couple of functions that lets you save a leaflet map somewhere other than a temp folder.
See the gist here: https://gist.github.com/barryrowlingson/d066a7ace15cf119681a for the full info, the short version is these two functions:
saveas <- function(map, file){
class(map) <- c("saveas",class(map))
attr(map,"filesave")=file
map
}
print.saveas <- function(x, ...){
class(x) = class(x)[class(x)!="saveas"]
htmltools::save_html(x, file=attr(x,"filesave"))
}
then all you do is:
leaflet() %>% etc etc %>% saveas("/wherever/you/want/index.html")
or in your mode of working:
mymap <- leaflet()
mymap <- addwhatever(mymap)
saveas(mymap, "/wherever/you/want/index.html")
At that point the folder /wherever/you/want
should have a self-contained set of files for the map. I think it should be portable, ie work on any web server, but I can't guarantee that...