# NOT RUN {
library(terra)
f <- system.file("extdata/cyl.gpkg", package = "tidyterra")
v <- terra::vect(f)
# Add NAs
v <- v %>% mutate(iso2 = ifelse(cpro <= "09", NA, cpro))
# Init
plot(v, col = "red")
# Mask with lyr.1
v %>%
drop_na(iso2) %>%
plot(col = "red")
# }
Run the code above in your browser using DataLab