Leaflet似乎没有打印所有标记?

时间:2015-10-06 06:43:10

标签: r leaflet

我在R /传单中打印地图并且缺少标记。在下面的例子中应该有大约100个标记,但我只看到它的一小部分。我错过了什么?

library(leaflet)
library(data.table)
library(nycflights13)

data(flights); data(airports)
setDT(flights); setDT(airports)

dest.counts = flights[, .N, by = dest]
dest.counts = merge(dest.counts, airports, by.x = "dest", by.y = "faa", all.x = T)

leaflet(dest.counts) %>% addTiles() %>%
  addCircles(radius = sqrt(dest.counts$N) * 200, popup = ~name) %>%
  setView(-95.31, 28.81, zoom = 4)

1 个答案:

答案 0 :(得分:5)

您“缺少”缺失值(NA)。删除它们将绘制所有圆圈:

leaflet(na.omit(dest.counts)) %>% addTiles() %>%
  addCircles(radius = sqrt(dest.counts$N) * 200, popup = ~name) %>%
  setView(-95.31, 28.81, zoom = 4)

enter image description here