简体   繁体   中英

interactive map using tmap package with RMarkdown

I am trying to write a report about my program and to show my work using RMarkdown. However, the map that I am currently using is generated by tmap package.

The shapefile can be downloaded here

The way that I make it interactive using R is

library(tmap)
library(rgdal)
map <- readOGR("Malaysia SHP", "MYS_adm1")
tmap_mode("view")
tm_shape(map) + tm_polygons()

This would generate an interactive map that we can directly access from R.

I want to include this in my RMarkdown and still make it interactive. I know there is a package called leaflet that is usually used to create an interactive map. Is there any way to create an interactive map using tmap in RMarkdown without using leaflet ?

Any helps would be appreciated. Thank you!

Thanks for this bug report! It is now fixed in the development version. See https://github.com/mtennekes/tmap how to install this.

If you cannot install the development version, a workaround is:

tmap_leaflet(tm_shape(map) + tm_polygons())

It coerces a tmap object to a leaflet object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM