This is just an expansion on @Ista’s answer, which does not require that one knows which states (Berlin, Bremen) need to be rendered last.
This approach takes advantage of the fact that fortify(...)
generates a column, hole
which identifies whether a group of coordinates are a hole. So this renders all regions (id’s) with any holes before (e.g. underneath) the regions without holes.
Many thanks to @Ista, without whose answer I could not have come up with this (believe me, I spent many hours trying…)
ggplot(map.df, aes(x=long, y=lat, group=group)) +
geom_polygon(data=map.df[map.df$id %in% map.df[map.df$hole,]$id,],aes(fill=poverty))+
geom_polygon(data=map.df[!map.df$id %in% map.df[map.df$hole,]$id,],aes(fill=poverty))+
geom_path(colour="grey50")+
scale_fill_gradientn(colours=brewer.pal(5,"OrRd"))+
labs(x="",y="")+ theme_bw()+
coord_fixed()