2017-10-18 42 views
4

我目前在Windows上运行R版本3.4.2,并且有ggplot2(通过tidyverse)和sf软件包版本3.4.2。我正在尝试使用ggplot2 sf工具包映射空间数据。错误:找不到函数“geom_sf”

当试图运行geom_sf时,我收到一个错误:could not find function "geom_sf"

当我使用ls("package:ggplot2")搜索ggplot2软件包时,geom_sf未在库文件中列出。

我安装了devtools并运行了devtools::install_github("tidyverse/ggplot2")。但是,我收到一个错误:Installation failed: Failed to connect to raw.githubusercontent.come port 443: Timed out。我假设防火墙正在停止这个连接。

为了解决这个问题,我尝试从https://github.com/tidyverse/ggplot2手动下载zip并运行install.packages('ggplot2-master.zip', lib = 'C:/filepath')并收到错误:package 'ggplot2-master.zip' is not available (for R version 3.4.2)。在从3.4.1更新之前,我收到了同样的错误。

TLDR:我有同样的问题,因为该用户:Error when plotting sf object --- Error: could not find function "geom_sf" 但解决方案并不为我工作。

有没有人看到我可能错过了什么?或者如何访问这个高度引用(更精简)的包?

+0

如果您下载压缩包,您需要按照从本地源安装它的过程,[在此解释](https://stackoverflow.com/q/1474081/903061)。在'install.packages()'中使用'repos = NULL,type =“source”'参数。 – Gregor

+1

我不认为“源”将是一个zip文件的正确设置。 –

回答

1

如果你从那么你提到的网址下载相应的下一步将是在R对话命令行来执行此假设你的包是在工作目录:

install.packages('ggplot2', repo=NULL, lib = 'C:/filepath') 

.zip扩展是隐式在试图从一个二进制Windows文件安装,你需要告诉它不要尝试从CRAN下载。