问题
I have recently encountered issues with the ggmap functions - had never had any.
I have this data.frame:
> head(df)
longitude latitude freq
1 -118.7093 34.13446 2
2 -118.7092 34.13437 1
3 -118.6851 34.28574 5
4 -118.5986 34.26155 1
5 -118.5917 34.22762 6
6 -118.5914 34.37675 1
I used to be able to get a map using get_map then plot the plots the raster object using ggmap. I would then use + geom_point or whichever to plot my data, worked like a charm.
map <- get_map(location=c(lon=-117.962813,lat=33.969399), zoom=10, maptype="hybrid")
finalmap <- ggmap(map, base_layer = ggplot(aes(x=longitude, y=latitude), data = df))
However now ggmap returns:
Error in annotate("rect", xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, :
unused arguments (xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax, fill = darken[2], alpha = as.numeric(darken[1]))
As anyone else encountered this?
回答1:
I encountered the same problem and logged in for the first time to post my solution. It seemed that I was loading a package (after loading ggplot) with a function called 'anotate' (from package tm) which masked the annotate function from ggplot. If you type annotate you should see if the function you're calling is actually from the ggplot package or from anoother one. Also be sure to check the messages when you're loading the packages.
Cheers
回答2:
The package NLP also has an annotate function...
You can dettach ggplot: detach("package:ggplot2", unload=TRUE)
and then load it again: library(ggplot2)
to make sure that the function is the one you want.
Hope it helps.
来源:https://stackoverflow.com/questions/25179889/ggmap-error-in-annotate