0

When I try to save my plot as an HTML file, I got this error:

Error in `+.tmap`(e1 = tm, e2 = do.call("tm_layout", args)) : object 'tm' not found

Here is my code:

tm_shape(countries_spdf) +
  tm_grid(n.x = 11, n.y = 11) +
  tm_fill(col = "population", style = "quantile")  +
  tm_borders(col = "burlywood4")

# Save a static version "population.png" [success]
tmap_save(filename = "population.png")

# Save an interactive version "population.html" [fail]
tmap_save(filename = "population.html")

What should I do?

Yuhan Wang
  • 11
  • 1

1 Answers1

0

Try two things:

  1. run everything without the call to tmap_save(filename = "population.png").

  2. Assign the map to an object.

     Map <- tm_shape(countries_spdf) +
      tm_grid(n.x = 11, n.y = 11) +
      tm_fill(col = "population", style = "quantile")  +
      tm_borders(col = "burlywood4")
    
     tmap_save(tm = Map, filename = "population.html")
    
Orlando Sabogal
  • 1,470
  • 7
  • 20