问题描述
我当前在Windows上运行R版本3.4.2,并且具有ggplot2(通过tidyverse)和sf软件包版本3.4.2.我正在尝试使用ggplot2 SF工具包映射空间数据.
I'm currently running R version 3.4.2 on Windows and have ggplot2 (via tidyverse) and sf package versions 3.4.2. I'm attempting to map spatial data using the ggplot2 sf kit.
尝试运行geom_sf时,出现错误:could not find function "geom_sf"
.
When trying to run geom_sf, I receive an error: could not find function "geom_sf"
.
当我使用ls("package:ggplot2")
搜索ggplot2软件包时,库文件中未列出geom_sf.
When I search the ggplot2 package using ls("package:ggplot2")
, geom_sf is not listed in the library files.
我安装了devtools并运行了devtools::install_github("tidyverse/ggplot2")
.但是,我收到一个错误:Installation failed: Failed to connect to raw.githubusercontent.come port 443: Timed out
.我认为正在工作的防火墙会中断此连接.
I installed devtools and ran devtools::install_github("tidyverse/ggplot2")
. However, I receive an error: Installation failed: Failed to connect to raw.githubusercontent.come port 443: Timed out
. I assume the firewall at work is halting this connection.
要解决此问题,我尝试从 https://github.com/tidyverse/ggplot2 并运行install.packages('ggplot2-master.zip', lib = 'C:/filepath')
并收到错误:package 'ggplot2-master.zip' is not available (for R version 3.4.2)
.从3.4.1.更新之前,我遇到了相同的错误.
To get around this, I tried downloading the zip manually from https://github.com/tidyverse/ggplot2 and running install.packages('ggplot2-master.zip', lib = 'C:/filepath')
and receive the error: package 'ggplot2-master.zip' is not available (for R version 3.4.2)
. I was getting the same error before I updated from 3.4.1.
TLDR :我与此用户有相同的问题:但是该解决方案对我不起作用.
TLDR: I'm having the same issue as this user: Error when plotting sf object --- Error: could not find function "geom_sf"but the solution does not work for me.
有人看到我可能在想什么吗?还是如何访问这个高度引用(更加简化)的软件包?
推荐答案
如果从引用的URL下载,则适当的下一步是在R会话命令行执行此操作,假设您的软件包位于工作目录中:
If you downloaded from the URL you cited then the appropriate next step would be to execute this at the R session command line assuming your package is in the working directory:
install.packages('ggplot2', repo=NULL, lib = 'C:/filepath')
.zip
扩展名隐含在尝试从Windows二进制文件安装的过程中,您需要告诉它不要尝试从CRAN下载.
The .zip
extension is implicit in trying to install from a binary windows file and you need to tell it NOT to attempt downloading from CRAN.
这篇关于错误:找不到函数"geom_sf";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!