How can I keep polygons\'s information after shapefile? Let me try to explain:
I have a shapefile with this data:
> head(mapa@data)
ID C
I came across the same problem and was able to achieve the desired results using slightly different approach.
I have used the following code to read the shapes:
shps <- maptools::readShapePoly(fn = file.path("file",
"path",
"no extension"),
# Column with unique IDs
IDvar = "geoID")
and subsequently fortified the objet using the code:
shpsFort <- ggplot2::fortify(model = shps)
This created a data.frame object with the id value corresponding to the column passed in IDvar = "geoID". Adding any other data could be simply addressed via ordinary merge command.