Ggplot2警告“删除了包含缺失值(geom_segment)的X行”,而值似乎没有丢失

时间:2016-11-01 17:12:19

标签: ggplot2 ggmap

我正在尝试在ggplot2图中显示很多(3913)段(使用ggmap制图可视化)。

这是我的数据集,其中每一行都是一个段:

       lat1    long1      lat2    long2          w
1 -119.4093 49.00574 -119.4221 49.00955  4.3029279
2 -119.4093 49.00574 -119.4233 49.01523  0.3375000
3 -119.4896 49.00544 -119.5176 49.00582  0.1285714
4 -119.4896 49.00544 -119.5063 49.01168  1.2277778
5 -119.5176 49.00582 -119.5630 49.00582  0.0900000
6 -119.5176 49.00582 -119.5160 49.00898 45.2909774

Full dataset here: https://dl.dropboxusercontent.com/u/73950/csvLinesWetlands.csv

这是我的代码:

library(ggplot2)
library(ggmap)

# Get the map from Google and put it in ggmap:
al1 = get_googlemap(center = c(lon = -119.539277502884, lat = 49.1698636938748), zoom = 10, scale = 2, maptype = 'terrain')
map = ggmap(al1, extent = 'device')

# Put CSV file in edges:
edges <- read.csv("/csvLinesWetlands.csv", header=TRUE)

# Draw all the segment in "map":
map <- map + geom_segment(data=edges, aes(x= long1, y=lat1, xend=long2, yend=lat2))

不幸的是,运行此代码时收到以下警告消息:

  

删除了包含缺失值的3913行(geom_segment)

地图上实际上没有显示任何分段(3913是我的数据集中的行/分段总数)。

没有我所知道的遗漏数据......我在这里做错了什么?

PS。 Stackoverflow上有一些问题可以解决这个问题,但没有一个能帮助我解决这个问题。

0 个答案:

没有答案
相关问题