无法在R中使用register_google

问题描述 投票:0回答:2

我试图通过在R中使用ggmap来创建简单的K-means聚类。

我跑了:

if(!requireNamespace("devtools")) install.packages("devtools")
devtools::install_github("dkahle/ggmap", ref = "tidyup")

这是github / ggmap(https://github.com/dkahle/ggmap)的推荐。

但是,当我尝试使用时

register_google(key='MyAPI')

R不断发出无法找到函数register_google()的错误。已经安装并加载了ggmap。

我从各种来源检查(例如:https://github.com/dkahle/ggmap/issues/143),这表明重新启动R会话。仍然,函数register_google()不起作用。我的代码看起来像这样:

library(ggmap)
data14=read.csv("https://raw.githubusercontent.com/fivethirtyeight/uber-tlc-foil-response/master/uber-trip-data/uber-raw-data-apr14.csv")
register_google(key = "MyAPI") **This part does not work for me**
NYCMap <- get_map('New York',maptype = 'roadmap', zoom=10)
ggmap(NYCMap) + geom_point(aes(x=Lon[], y =Lat[]), data=data14)

任何帮助将非常感谢。如果您需要更多信息,请随时告诉我们。

编辑:R的输出和错误

> install.packages("ggmap")
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/ggmap_2.6.1.tgz'
Content type 'application/x-gzip' length 4565845 bytes (4.4 MB)
==================================================
downloaded 4.4 MB


The downloaded binary packages are in
    /var/folders/2k/y418d7qs7jdbwzyv6q4sz3gc0000gn/T//RtmpmTPB4Y/downloaded_packages
> if(!requireNamespace("devtools")) install.packages("devtools")
> devtools::install_github("dkahle/ggmap", ref = "tidyup")
Downloading GitHub repo dkahle/ggmap@tidyup
✔  checking for file ‘/private/var/folders/2k/y418d7qs7jdbwzyv6q4sz3gc0000gn/T/RtmpmTPB4Y/remotes87187e0df6f3/dkahle-ggmap-4dfe516/DESCRIPTION’ ...
─  preparing ‘ggmap’:
✔  checking DESCRIPTION meta-information ...
   Warning in as.POSIXlt.POSIXct(x, tz) :
     unknown timezone 'zone/tz/2018g.1.0/zoneinfo/America/New_York'
─  checking for LF line-endings in source and make files
─  checking for empty or unneeded directories
   Removed empty directory ‘ggmap/.github’
─  looking to see if a ‘data/datalist’ file should be added
─  building ‘ggmap_2.7.904.tar.gz’ (696ms)

Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
  unknown timezone 'zone/tz/2018g.1.0/zoneinfo/America/New_York'
* installing *source* package ‘ggmap’ ...
** R
** data
*** moving datasets to lazyload DB
** inst
** preparing package for lazy loading
Warning: package ‘ggplot2’ was built under R version 3.4.4
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Warning: package ‘ggplot2’ was built under R version 3.4.4
* DONE (ggmap)
> library(ggmap)
> register_google(key = "MyAPI")
Error in register_google(key = "MyAPI") : 
  could not find function "register_google"
r ggmap
2个回答
0
投票

我遇到了同样的问题。我正在使用macOS el-capitan。

以下是我要解决的步骤:

  • 确认您已删除(“ggmap”)'2.6.1'的CRAN版本。通过remove.packages(“ggmap”)
  • 一旦删除,您还需要使用上述方法确认删除(“tibble”)。
  • devtools :: install_github(“dkahle / ggmap”,ref =“tidyup”)
  • 系统将提示您安装tibble,选择“Y”
  • 安装应该开始
  • 如果被问到“你想从源代码安装需要编译的软件包吗?”选择否

0
投票

我用过这个并且工作过。

install.packages("devtools")
devtools::install_github("dkahle/ggmap")
library(ggmap)
library(devtools)

然后你可以使用register_google()

© www.soinside.com 2019 - 2024. All rights reserved.