c.f. yutannihilation/gghighlight#81
library(ggplot2)
library(gghighlight)
library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
data(tornados, package = "GISTools")
nc <- st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
us_states <- st_as_sf(us_states)
#> Loading required package: sp
# fail
ggplot(nc) +
geom_sf(data = us_states) + # Supplemental Layer 2
geom_sf(aes(fill = AREA)) + # Target Layer for gghighlight
gghighlight(grepl("^[A-C]", NAME))
#> Error in merge_mapping(layer, plot_mapping): No mapping found on this layer!
# fail
ggplot(nc, aes(geometry = geometry)) +
geom_sf(data = us_states) + # Supplemental Layer 2
geom_sf(aes(fill = AREA)) + # Target Layer for gghighlight
gghighlight(grepl("^[A-C]", NAME))
#> Error in if (aes_param_name %in% names(geom$default_aes) && is.na(geom$default_aes[[aes_param_name]])) {: missing value where TRUE/FALSE needed
Created on 2019-01-05 by the reprex package (v0.2.1)