Pregunta

Am I wrong, or is there an issue with the ggmap zoom argument scope? If I run the following it gives me the error object 'thezoom' not found:

myfunction<-function(thezoom=14){
  qmap(location = 'baylor university', zoom = thezoom)
}

myfunction()

But if thezoom is in the global scope like below it works:

thezoom=14
myfunction<-function(){
  qmap(location = 'baylor university', zoom = thezoom)
}

myfunction()

I'm trying to write a function that allows the user to specify zoom, but I'm having a little trouble.

Thoughts?

ZR

¿Fue útil?

Solución

Instead of qmap, using get_map and ggmap functions also works.

library(ggmap)

myfunction<-function(thezoom=14){
  ggmap(get_map(location = 'baylor university', zoom = thezoom))
}

myfunction()    # Draws a map with zoom set to 14
myfunction(10)  # Draws a map with zoom set to 10
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top