0
votes

I am trying to make a map using ggmap pulling the image from google. Below is my code where I am trying to pull a plot of Utah and then plot it.

The plot will not be made because of the error that I receive: "error in as.vector(y) : attempt to apply non-function."

Any clue on what is going on and why it won't work?

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
#pull map of Utah

Ut.map <- get_map(location=c(-111, 39.5), zoom=7, maptype="roadmap")

Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=39.5,-111&zoom=7&size=640x640&scale=2&maptype=roadmap&language=en-EN&sensor=false

ggmap(Ut.map)

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

Edit: 11/14/2016 4:00 pm

I updated R, Rstudio, and ggplot2. Now I receive this error message when I try to load ggplot2:

library(ggplot2)
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
there is no package called ‘Rcpp’
Error: package or namespace load failed for ‘ggplot2’

I tried to install Rcpp and I receive this message:

install.packages("Rcpp")
Installing package into ‘C:/Users/justi/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
trying URL
'https://cran.rstudio.com/bin/windows/contrib/3.3/Rcpp_0.12.7.zip'
Content type 'application/zip' length 3265506 bytes (3.1 MB)
downloaded 3.1 MB

package ‘Rcpp’ successfully unpacked and MD5 sums checked
Warning in install.packages :
unable to move temporary installation ‘C:\Users\justi\Documents\R\win-     
library\3.3\file150426f11cb7\Rcpp’ to ‘C:\Users\justi\Documents\R\win-  
library\3.3\Rcpp’

The downloaded binary packages are in
C:\Users\justi\AppData\Local\Temp\RtmpesXik0\downloaded_packages

Now I can't run anything related to ggplot or anything. My new R details are:

R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
3
works fine for me, restart RMateusz1981
restart didn't work. Reinstall made it even worse (see above edit)Justin

3 Answers

1
votes

Fixed the problem! So another person had issues installing the Rcpp package (https://github.com/hadley/dplyr/issues/2002)

Following their advise, I suspended my antivirus coverage and was able to easily install all packages with no errors.

Following this complete reinstall of R, Rstudio, ggplot2, and ggmap, I was finally able to get the plot with no issues.

Helpful advise for anyone in the future, try deactivating your antivirus to install updates to packages!

0
votes

I had the same problem just this morning, with code that worked for me last week. The only change I can think of is an accidental reinstall of the ggmap package.

After updating the ggplot2 package I was actually able to generate a map and no longer received the error, hope that helps.

0
votes

I had same error message, so I tried to update ggplot2 package and it works - now version 2.2.0, R in version x64 3.3.1. Hope it will also work for you.