Error When Plotting Sf Object --- Error: Could Not Find Function "Geom_Sf"

Error when plotting sf object --- Error: could not find function geom_sf

While running R as the administrator, reinstall ggplot2 like this:

devtools::install_github("tidyverse/ggplot2")
require(ggplot2)

You should be able to see it now with ?geom_sf

For questions related to using devtools, see this SO answer.

Error: could not find function geom_sf

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.

How to change longitude default label in maps created with sf?

You can define a function that handles the axis

makeLong <- function(x) paste0(-x, "\u00b0O") # \u00b0 is the Unicode degree symbol

Now you pass this function to the labels

ggplot(data = nc) + geom_sf() + scale_x_continuous(labels = makeLong)

Size legend of sf object won't show correct symbols

you need to add the show.legend argument to geom_sf, i.e.

nc_centers %>%
ggplot() +
geom_sf(aes(color = SID79, size = BIR74), show.legend = 'point') +
coord_sf(datum = NA) +
theme_minimal()

Sample Image



Related Topics



Leave a reply



Submit