I've been using ggmap for several years now. A few weeks ago I started getting weird error messages when plotting with it; not sure if I did anything to cause it. It seems that the problems start when I try to use more than the coords - any other aesthetic use (colour / fill / etc) results in an error, as does facetting.
To address this, I installed R 3.5.1 and re-installed the ggmap package to make sure I'm using the most up-to-date stuff. I'm assuming the issue is with me and not the package, since I didn't see anything similar when googling.
toy data:
library(ggplot2)
library(ggmap)
df <- data.frame(Group = sample(LETTERS[1:2], 20, replace = TRUE),
x = rnorm(20, -116.1, 0.001), y = rnorm(20, 48.5, 0.001))
prep <- get_googlemap(center = c(-116.1, 48.5),
zoom = 15, maptype = 'satellite', scale = 2)
runs ok, but gives a warning that "panel.margin is deprecated"
map <- ggmap(prep, size = c(100, 200),
extent='device', darken = 0,
legend = "bottom", data = df)
gives a long output of theme elements that are missing, but plots the output
map +
geom_point(data = df, aes(x = x, y = y), colour = "white") +
facet_wrap(~ Group)
gives a long output of theme elements that are missing, as well as an error Error in unit(rep(just$hjust, n), "npc") : 'x' and 'units' must have length > 0
map +
geom_point(data = df, aes(x = x, y = y), colour = "white") +
facet_wrap(~ Group)
also long list of missing theme elements, as well as a different error: Error in UseMethod("element_grob") : no applicable method for 'element_grob' applied to an object of class "NULL"
map +
geom_point(data = df, aes(x = x, y = y, colour = Group))
session info: R version 3.5.1 (2018-07-02) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1 ggmap version: 2.6.1
Answered in comments. Solution was:
devtools::install_github("dkahle/ggmap", ref = "tidyup")