当我尝试将我的绘图另存为 HTML 文件时,出现此错误:
Error in `+.tmap`(e1 = tm, e2 = do.call("tm_layout", args)) : object 'tm' not found
这是我的代码:
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")
我该怎么办?
尝试两件事:
-
在不调用tmap_save(文件名 = "population.png"(的情况下运行所有内容。
-
将映射分配给对象。
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")