R ggmap ggplot2 error "Error: Discrete value supplied to continuous scale" -


first of all, apologise.

i know there numerous threads error, have tried numerous solutions , have not managed solve issue.

i have tried transforming data numerous forms still same error, or ggplot2 not support data format.

here code:

library(ggmap) library(ggplot2) library(data.table)  setwd("~/projects/reformat") map <- get_map(location = c(-4,54.5), zoom = 6) data <- read.csv('lonlatprice.csv') colnames(data) <- c('longitude','latitude','price')  ggmap(map, extent = "device") + geom_point(aes(x = data$longitude, y = data$latitude), colour = "red",                                                   alpha = 0.1, size = 2) 

this data format like:

> head(data)   longitude   latitude  price 1 53.778274   -2.48129 147500 2 52.833819  -0.936527 182000 3 50.792457   0.046043 193000 4 51.476984  -0.612126 580000 5 51.460139   -0.01867 905000 6 52.235942   1.519404 641500 

thanks in advance help, have asked last resort after numerous days of no success.

there several problems code:

  1. you retrieved wrong map. mixed order of lon , lat values in get_map(location = c(-4,54.5), zoom = 6)
  2. you calling data in geom_point part in wrong way.

the following code fixes these problems:

map <- get_map(location = c(51.5,0.2), zoom = 6)  ggmap(map) +    geom_point(data= data,              aes(x = longitude, y = latitude),              colour = "red",              alpha = 0.5,              size = 4) 

and gives map:

enter image description here


Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -