2

我错了,还是 ggmap 缩放参数范围有问题?如果我运行以下命令,它会给我找不到错误对象“thezoom”:

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

myfunction()

但是如果 thezoom 在全局范围内,如下所示:

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

myfunction()

我正在尝试编写一个允许用户指定缩放的函数,但我遇到了一些麻烦。

想法?

ZR

4

1 回答 1

2

代替qmap,使用get_mapggmap函数也可以。

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
于 2014-03-22T03:52:00.073 回答