10

I'm doing relatively simple things with ggmap and am confused because code that runs fine on my mac does not run on my PC.

I run this code:

library(ggmap)

map <- get_map(location = c(-122.175, 37.45635),
               maptype = "terrain",
               source = "google",
               crop = FALSE,
               zoom = 7)
 ggmap(map)

, which runs fine on my mac, but throws this error on my PC:

Error in as.vector(y) : attempt to apply non-function

Any help would be much appreciated.

leb112358
  • 101
  • 1
  • 4
  • Unable to reproduce, works fine on my Windows machine. Try restarting R, or reinstalling the package. – ytk Nov 15 '16 at 17:11
  • Right, it works fine on my mac as well + I of course already tried restarting R and restarting my computer. That's why I posted the question - to see if anyone might have any ideas on what could be going wrong on a PC. Thanks though. – leb112358 Nov 15 '16 at 19:29

4 Answers4

3

It is no longer necessary to uninstall ggplot2 to fix this error. I was able to update ggplot by running install.packages("ggplot2"), then reinstall ggmap. This solved the problem for me.

2

I faced that problem after installing R and RStudio last week. Restarting RStudio or R session, or reinstalling ggmap package didn't work for me. I'd just fixed it with these steps:

  • Uninstall R and RStudio
  • Delete old folders related to R and RStudio in Program Files (I had things like older versions of R).
  • Delete Windows temporary files (just in case)
  • Install R and RStudio again
  • Install ggmap package
Martin
  • 51
  • 1
  • 9
1

I guess this problem comes from the last update of ggplot2. See the following links:

You could try to install an older version of ggplot (see below) or try to reinstall the packages like suggested in the link above.

    library(devtools)
    install_version("ggplot2", version = "2.1.0", repos = "http://cran.us.r-project.org")
Community
  • 1
  • 1
Benjamin Ziepert
  • 1,345
  • 1
  • 15
  • 19
  • Yes, I ended up then having this same trouble on my mac and this solution also worked for me -- thank you! (But also a bummer that I can't also utilize the new ggplot2 features - oh welll - this is what iterations are for I suppose!) – leb112358 Nov 17 '16 at 15:48
  • My experience seems to be the opposite (in Windows with RStudio): I had this error with ggplot2 2.1.0 and solved it by upgrading to ggplot2 2.2.1. – Pere Sep 13 '17 at 08:47
1

You don't need to Unistall R. Just erase ALL folders related to ggplot2, and reinstall the ggmap with all dependencies.