Ggplot does not build a ggmap object

When I run the code from the accepted answer ( Graphic coordinates on the map ), I get the following error message the first time I run it after installing ggmap:

# loading the required packages library(ggplot2) library(ggmap) # creating a sample data.frame with your lat/lon points lon <- c(-38.31,-35.5) lat <- c(40.96, 37.5) df <- as.data.frame(cbind(lon,lat)) # getting the map mapgilbert <- get_map(location = c(lon = mean(df$lon), lat = mean(df$lat)), zoom = 4, maptype = "satellite", scale = 2) # plotting the map with some points on it ggmap(mapgilbert) + geom_point(data = df, aes(x = lon, y = lat, fill = "red", alpha = 0.8), size = 5, shape = 21) + guides(fill=FALSE, alpha=FALSE, size=FALSE) 

which gives an error:

Error: GeomRasterAnn was created with an incompatible version of ggproto. Reinstall the package that this extension provides.

I tried to install ggproto, but the error:

 > Warning in install.packages : package 'ggproto' is not available (for R version 3.3.2) 

On subsequent attempts, the error:

Error: ggplot2 does not know how to handle ggmap / raster class data

I can build the image using:

 plot(mapgilbert) 

I tried:

 map2 <- get_map("Rotorua", zoom = 16) ggmap(data = map2) 

who returned the following error message:

Error: ggplot2 does not know how to handle ggmap / raster class data

I just don’t know R well enough to find out where to look for a solution to a solution - they provided updates for all packages.

0
source share
1 answer

This is probably a version error because your code works fine on my machine (R 3.3.2). devtools::install_github("dkahle/ggmap") devtools::install_github("hadley/ggplot2")

You can download the devtools packages and install ggmap and ggplot2 from github again.

+1
source

Source: https://habr.com/ru/post/1263420/


All Articles