Les délégations où Nahdha a gagné des votes.
On présentera d’abord les délégation où la différence entre 2014 et 2011 est positive.
Pour cela on garde dans l’obbjet tun_df2 les lignes ouù la différence est restée positive (Nahdha a soit gardé le même nombre d’élécteurs ou elle en a gagné).
> i=which(tun_df2$Nahdha_2014-tun_df3$Nahdha_2011 >=0)
> tun_df2A=tun_df2[i,]
> tun_dfA=data.frame(c(tun_df2A$id,tun_df3$id),c(tun_df2A$long,tun_df3$long),c(tun_df2A$lat,tun_df3$lat),
+ c(tun_df2A$order,tun_df3$order),c(tun_df2A$hole,tun_df3$hole),
+ c(tun_df2A$piece,tun_df3$piece),c(tun_df2A$group,tun_df3$group),
+ c(tun_df2A$Nahdha_2014,tun_df3$Nahdha_2011),
+ c(as.character(tun_df2A$Region),as.character(tun_df3$Region)),
+ c(rep("2014",length(i)),rep("2011",3490)))
> colnames(tun_dfA)=c(colnames(tun_df2)[-c(8,9)],"Nahdha","Region","Year")
> head(tun_dfA)
id long lat order hole piece group Nahdha Region Year
1 TS2134 4355599 1370631 1673 FALSE 1 157 1042 Centre-est 2014
2 TS2134 4356971 1368746 1674 FALSE 1 157 1042 Centre-est 2014
3 TS2134 4351256 1367522 1675 FALSE 1 157 1042 Centre-est 2014
4 TS2134 4344645 1358415 1676 FALSE 1 157 1042 Centre-est 2014
5 TS2134 4351729 1354280 1677 FALSE 1 157 1042 Centre-est 2014
6 TS2134 4353369 1350181 1678 FALSE 1 157 1042 Centre-est 2014
> p<-ggplot(tun_dfA, aes(x=long, y=lat, group=group)) +
+ geom_polygon(aes(fill=Nahdha),color = "grey50")+
+ scale_fill_gradientn(colours=brewer.pal(5,"OrRd"),name="Nahdha")+
+ labs(x="",y="")+ theme_bw()+facet_grid(~Year)+
+ coord_fixed()
> p<-p+theme(axis.line=element_blank(),
+ axis.text.x=element_blank(),
+ axis.text.y=element_blank(),
+ axis.ticks=element_blank(),
+ axis.title.x=element_blank(),
+ axis.title.y=element_blank(),panel.grid.major = element_blank(),
+ panel.grid.minor = element_blank(),
+ panel.border = element_blank(),
+ panel.background = element_blank())
> p<-p+ theme(legend.position="right")
> p

Maintenant les délégations où Nahdha a perdu des votes.
> i=which(tun_df2$Nahdha_2014-tun_df3$Nahdha_2011<0)
> tun_df2A=tun_df2[i,]
> tun_dfA=data.frame(c(tun_df2A$id,tun_df3$id),c(tun_df2A$long,tun_df3$long),c(tun_df2A$lat,tun_df3$lat),
+ c(tun_df2A$order,tun_df3$order),c(tun_df2A$hole,tun_df3$hole),
+ c(tun_df2A$piece,tun_df3$piece),c(tun_df2A$group,tun_df3$group),
+ c(tun_df2A$Nahdha_2014,tun_df3$Nahdha_2011),
+ c(as.character(tun_df2A$Region),as.character(tun_df3$Region)),
+ c(rep("2014",length(i)),rep("2011",3490)))
> colnames(tun_dfA)=c(colnames(tun_df2)[-c(8,9)],"Nahdha","Region","Year")
> head(tun_dfA)
id long lat order hole piece group Nahdha Region Year
1 TS1110 4350192 1529845 1 FALSE 1 1 2418 Nord-est 2014
2 TS1110 4346729 1530476 2 FALSE 1 1 2418 Nord-est 2014
3 TS1110 4347480 1532800 3 FALSE 1 1 2418 Nord-est 2014
4 TS1110 4352078 1534408 4 FALSE 1 1 2418 Nord-est 2014
5 TS1110 4350192 1529845 5 FALSE 1 1 2418 Nord-est 2014
6 TS1111 4336246 1526804 6 FALSE 1 2 3042 Nord-est 2014
> p<-ggplot(tun_dfA, aes(x=long, y=lat, group=group)) +
+ geom_polygon(aes(fill=Nahdha),color = "grey50")+
+ scale_fill_gradientn(colours=brewer.pal(5,"OrRd"),name="Nahdha")+
+ labs(x="",y="")+ theme_bw()+facet_grid(~Year)+
+ coord_fixed()
> p<-p+theme(axis.line=element_blank(),
+ axis.text.x=element_blank(),
+ axis.text.y=element_blank(),
+ axis.ticks=element_blank(),
+ axis.title.x=element_blank(),
+ axis.title.y=element_blank(),panel.grid.major = element_blank(),
+ panel.grid.minor = element_blank(),
+ panel.border = element_blank(),
+ panel.background = element_blank())
> p<-p+ theme(legend.position="right")
> p
