title: Save leaflet maps as pictures (png, jpeg) in R Studio
body: <p>I would like to create an animated map, based on leaflet maps, using R Studio. Previously this was working with ggmaps &amp; ggplot using saveHTML, but the function saveHTML is unable to make images of the leaflet maps and hence not able to make a html page showing an animated map.</p>
  
  <p>Any suggestions how to save leaflet maps as images, or how to use saveHTML to get an animated map?</p>
  
  <p>Data looks like:</p>
  
  <pre><code>long = c(-73.95,-74,-74.05)
  lat = c(40.8, 40.7, 40.4)
  minute = c(15, 0, 18)
  tripData &lt;- data.frame(long,lat,minute)
  </code></pre>
  
  <p>Code so far:</p>
  
  <pre><code>library(animation)
  library(leaflet)
  
  plotLeaflet &lt;- function(.minute){
    df = subset(tripData, minute == .minute);
    (m2 &lt;- m %&gt;% addCircles(data = df));
    print(m2);
  }
  
  # Create animation
  range_m = 0:59
  
  oopt &lt;- animation::ani.options(interval = 0.1)
  
  FUN3 &lt;- function() {
    mapply(function(x) {
      plotLeaflet(x);
      animation::ani.pause()
    },range_m)
  }
  
  
  saveHTML(FUN3(), autoplay = FALSE, loop = FALSE, verbose = FALSE, outdir = "images/animate/new",
           single.opts = "'controls': ['first', 'previous', 'play', 'next', 'last', 'loop', 'speed'], 'delayMin': 0")
  </code></pre>
  
  <p>Help will be highly appreciated!</p>