我很难根据参数值设置点数大小"点击"在我的情况下,理想的大小命令应该工作,但它不能以某种方式为我工作。它抛出我的错误错误:设置美学的不兼容长度:大小 这是我的努力:
library(ggmap)
library(ggplot2)
map <- get_googlemap(center = c(lon = -73.99, lat = 40.75), color = "bw", scale = 2,zoom=12)
x <- ggmap(map,extent = "device") +geom_point(aes(longitude.x, latitude.x,colour=factor(geo_region)),
data=data_ny, na.rm=T,size=3)+ scale_size_continuous(range =range(data_ny$clicks))
x
DPUT是:
structure(list(geo_region = structure(c(1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "NY", class = "factor"),
io_id = c(262046L, 262045L, 262048L, 262046L, 262048L, 262048L,
262045L, 262046L, 262046L, 262048L, 262048L, 262046L, 262046L,
262048L, 262048L, 262046L, 262046L, 262048L, 262046L, 262048L,
262045L, 262046L, 262048L, 262045L, 262048L, 262045L, 262046L,
262048L, 262045L, 262046L, 262045L, 262048L, 262046L, 262048L,
262045L, 262046L, 262048L, 262045L, 262046L, 262046L, 262045L,
262048L, 262046L, 262045L, 262048L, 262045L, 262048L, 262046L,
262046L, 262048L), city.x = c("new york", "new york", "new york",
"new york", "new york", "new york", "new york", "new york",
"new york", "new york", "new york", "new york", "new york",
"new york", "new york", "new york", "new york", "new york",
"new york", "new york", "new york", "new york", "new york",
"new york", "new york", "new york", "new york", "new york",
"new york", "new york", "new york", "new york", "new york",
"new york", "new york", "new york", "new york", "new york",
"new york", "new york", "new york", "new york", "new york",
"new york", "new york", "new york", "new york", "new york",
"new york", "new york"), latitude.x = c(40.75, 40.75, 40.75,
40.72, 40.72, 40.73, 40.73, 40.73, 40.7, 40.7, 40.71, 40.71,
40.71, 40.71, 40.71, 40.71, 40.71, 40.71, 40.72, 40.72, 40.72,
40.74, 40.74, 40.74, 40.74, 40.74, 40.74, 40.72, 40.72, 40.72,
40.72, 40.72, 40.72, 40.73, 40.73, 40.73, 40.75, 40.75, 40.75,
40.75, 40.75, 40.75, 40.76, 40.76, 40.76, 40.76, 40.76, 40.76,
40.76, 40.76), longitude.x = c(-73.99, -73.99, -73.99, -73.99,
-73.99, -73.99, -73.99, -73.99, -74.01, -74.01, -74.01, -74.01,
-74.01, -74.01, -74.01, -74.01, -74.01, -74.01, -73.98, -73.98,
-73.98, -73.99, -73.99, -73.99, -74, -74, -74, -74, -74,
-74, -74, -74, -74, -74.01, -74.01, -74.01, -73.98, -73.98,
-73.98, -73.97, -73.97, -73.97, -73.99, -73.99, -73.99, -73.99,
-73.99, -73.99, -73.98, -73.98), clicks = c(30L, 0L, 9L,
12L, 3L, 15L, 0L, 30L, 3L, 4L, 4L, 22L, 2L, 0L, 4L, 3L, 0L,
0L, 15L, 14L, 0L, 10L, 3L, 0L, 24L, 0L, 44L, 9L, 0L, 11L,
0L, 11L, 11L, 8L, 0L, 11L, 20L, 0L, 49L, 24L, 0L, 12L, 13L,
0L, 15L, 0L, 14L, 30L, 4L, 4L)), .Names = c("geo_region",
"io_id", "city.x", "latitude.x", "longitude.x", "clicks"), row.names = c(NA,
50L), class = "data.frame")
,这是我得到的示例输出
但我希望根据点击次数调整大小。理想情况下 size = data_ny $ clicks 应该有效,但不是,任何人都可以帮我解决这个微不足道的问题。
答案 0 :(得分:3)