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()
Related Topics
How to Always Display 3 Decimal Places in Datatables in R Shiny
R 3.5 Is Not Available for Linux
Fill in Data Frame with Values from Rows Above
What Is the Internal Implementation of Lists
Package 'Pbkrtest' Is Not Available (For R Version 3.2.2)
Using Rollmean When There Are Missing Values (Na)
How to Create a Histogram from Aggregated Data in R
How to Output a Stem and Leaf Plot as a Plot
Select Last Row by Group for All Columns Data.Table
How to Use Variables Newly Created in 'J' in the Same 'J' Argument
Multi Line Title in Ggplot 2 with Multiple Italicized Words
Filling Bars in Barplot with Textiles in Ggplot2
Rename Columns in Multiple Dataframes, R
How to Filter on Partial Match Using Sparklyr