简体   繁体   中英

Error: could not find function “geom_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.

When trying to run geom_sf, I receive an error: could not find function "geom_sf" .

When I search the ggplot2 package using ls("package:ggplot2") , geom_sf is not listed in the library files.

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.

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 : 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.

Does anyone see where I may be missing something? Or how to access this highly referenced (more streamlined) package?

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')

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM