首页 文章

ggplot2 Mapping:不知道如何自动选择比例

提问于
浏览
0

我试图在区域 Map 上绘制地址 . 我的程序使用以下库:

# load libraries
library(ggplot2)
library(maptools)
library(mapproj)
library(plyr)
library(sp)
library(rgdal)
library(rgeos)
library(ggmap)

相关代码如下:

#Generating Map
#f.dist_1 contains longitude, latitude and a group id identifting precincts

distMap <- ggplot(data = f.dist_1, aes(x=longitude, y=latitude, group = id))

#Create map file and precinct outlines 

distMap <- distMap + geom_polygon(fill="aliceblue") 
distMap <- distMap + geom_path(color= "black",aes(group=group))

#f.canvassu2 contains household data, longitude ("lon") and latitude ("lat") value
#Plot selected households; this statement throws the error:

不知道如何自动选择类型函数对象的比例 . 默认为data.frame中的连续错误(x = c(-105.0038579,-105.003855,-105.002154,-105.001437,:参数意味着行数不同:48,0)

distMap <- distMap + geom_point(data=f.canvassu2,aes(x=lon, y=lat), size=2)

f.canvassu2数据框中的“log”和“lat”变量是数字 .

有谁知道为什么“不知道如何自动选择对象的比例......”错误发生?其他人如何解决这个错误?

1 回答

  • 0

    改用它

    # using aesthetic to just load data to map
    distMap <- distMap + aes(x=as.numeric(f.canvassu2$lon), y=as.numeric(f.canvassu2$lon)) + geom_point(size=2)
    
    # just check if map is displayed
    distMap
    

    让我知道它是否适合你 .

相关问题