retirement of rgeos/rgdal/maptools

The suggested course of action is to move to more current, actively developed packages. The actual type depends on your data - but for most vector data this would be {sf}, for spatio-temporal data {stars} and for raster data {terra}.

Also note that if you are following a tutorial that uses a rgdal call it is likely to be an oldish one (considering the breakneck dynamics of open source development) and liable to contain dated code. This can be in form of practices no longer considered "best" and / or using superseded tools & techniques - such as ggplot2::fortify() instead of ggplot2::geom_sf() to draw a map.

So proceed with extra caution - or consider a more recent tutorial, if one is available for your use case. But actually using rgdal in new code in 2022 is somewhat of a red flag.

If by "shape files" you mean the ESRI shapefiles I suggest sf::st_read(), as in:

library(sf)
library(ggplot2)

shape <- st_read(system.file("shape/nc.shp", package="sf"))   # included with sf package

ggplot(data = shape) +
  geom_sf()

1 Like