Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: could not find function "geom_sf"

Tags:

r

ggplot2

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?

like image 231
gprest Avatar asked Oct 18 '17 18:10

gprest


1 Answers

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.

like image 81
IRTFM Avatar answered Sep 22 '22 00:09

IRTFM