r - Unable to set size with ggmap -


i m struggling set size of points based on parameter value "clicks" in case, ideally size command should work not working me somehow.its throwing me error error: incompatible lengths set aesthetics: size here effort :

 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 

the 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") 

this sample output if fix size = 4 enter image description here

but want size dynamic based on clicks. ideally size=data_ny$clicks should work, not, can me fix trivial issue.

you had errors in names , thought adding alpha (transparency) specification resolve issues of adjacent overlapping points different numbers of clicks:

 x <- ggmap(map,extent = "device") +       geom_point(data=data_ny, aes(x=longitude.x, y=latitude.x),                  color="blue", alpha=0.3,                     size=na.omit(data_ny$clicks), na.rm=true ) +        scale_size_continuous(range =range(data_ny$clicks))  png(); print(x); dev.off() 

enter image description here


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -