Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 用传单把鼠标放在全国各地,看看它的名字_R_Leaflet_Mousehover - Fatal编程技术网

R 用传单把鼠标放在全国各地,看看它的名字

R 用传单把鼠标放在全国各地,看看它的名字,r,leaflet,mousehover,R,Leaflet,Mousehover,我正在制作一张世界地图: library(leaflet) library(rnaturalearth) countries <- rnaturalearth::countries110 mymap <- leaflet(countries) mymap %>% addPolygons(stroke = FALSE, smoothFactor = 0.2, fillOpacity = 1) 图书馆(传单) 图书馆(rnaturalearth) 国家我想出了一个解决办法。 首先

我正在制作一张世界地图:

library(leaflet)
library(rnaturalearth)
countries <- rnaturalearth::countries110
mymap <- leaflet(countries)
mymap %>% addPolygons(stroke = FALSE, smoothFactor = 0.2, fillOpacity = 1)
图书馆(传单)
图书馆(rnaturalearth)
国家我想出了一个解决办法。
首先,使用库“htmltools”创建标签列表
然后将其放在标签=。因此,最终代码是:

library(leaflet)
library(rnaturalearth)
library(htmltools)

countries <- rnaturalearth::countries110
mymap <- leaflet(countries)
labs <- as.list(countries$name)
mymap %>% addPolygons(stroke = FALSE, smoothFactor = 0.2, 
                      fillOpacity = 1, label = lapply(labs, HTML))
图书馆(传单)
图书馆(rnaturalearth)
图书馆(htmltools)
国家或更简单的是:

library(leaflet)
library(rnaturalearth)

countries <- rnaturalearth::countries110
mymap <- leaflet(countries)
mymap %>% addPolygons(stroke = FALSE, smoothFactor = 0.2, 
                      fillOpacity = 1, label = ~name)
图书馆(传单)
图书馆(rnaturalearth)
国家