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
Assumption that data$CD_GEOCODI and shape@data are both unique for each row. Below is a better and simpler answer:
library(dplyr)
library(ggplot2)
# fortify the shape file
map.df <- fortify(shape, region ="CD_GEOCODI")
# change data$CD_GEOCODI to character, as shp.df$CD_GEOCODI is of character class.
data <- data %>% mutate(data, CD_GEOCODI = as.character(CD_GEOCODI))
# merge data
map.df <- left_join(map.df, data, by=c('id'='CD_GEOCODI'))