| |
| rm(list=ls()) |
|
|
| |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
| library(ggplot2) |
| library(ggrepel) |
| library(plyr) |
| library(dplyr) |
| library(ggmap) |
| library(RColorBrewer) |
| library(reshape2) |
|
|
| s = function(x){summary(factor(x))} |
|
|
| |
| |
| C = readRDS('map_dataset_4-28-20.RDS') |
| |
| |
| map_19_cluster_offset = readRDS('map_out_4-28-20.RDS') |
|
|
| C = C %>% rename(Religion = C.C6_Religion.x) |
|
|
| |
| C$Cat = NA |
| C$Cat[which(C$Nearest10_OwnReligion <= 5)] = 0 |
| C$Cat[which(C$Nearest10_OwnReligion > 5 & C$Nearest10_OwnReligion <= 8)] = 1 |
| C$Cat[which(C$Nearest10_OwnReligion > 8)] = 2 |
| C$Cat = factor(C$Cat) |
|
|
| |
| D = C[seq(dim(C)[1],1),] |
|
|
| |
| sc_x_lo = min(D$pseudo_lon) + (max(D$pseudo_lon) - min(D$pseudo_lon)) * (1/10) |
| sc_y = min(D$pseudo_lat) + (max(D$pseudo_lat) - min(D$pseudo_lat)) * (9.34/10) |
|
|
| |
| |
| ggmap(map_19_cluster_offset) + geom_point(data = D, aes(x=pseudo_lon, y=pseudo_lat, shape = Religion, fill=Cat), |
| size=6.7, alpha=1, color = 'white') + |
| geom_segment(aes(x=sc_x_lo, xend=sc_x_lo + 0.0005/1.0835,y=sc_y,yend=sc_y),color='white', size = 1.05) + |
| geom_text(aes(x=sc_x_lo + 0.00065,y=sc_y-0.0000),label='50 m',color='white', size = 6.5) + |
| 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(), |
| legend.title = element_text(size = 14), |
| legend.text = element_text(size = 12)) + |
| scale_fill_grey('10-nearest-\nneighbors', labels = c('(0,5]','(5,8]','(8,10]')) + |
| scale_shape_manual('Religion', values = c(24, 21), labels = c('Hindu','Muslim')) + |
| guides(fill=guide_legend(override.aes=list(shape=21)), |
| shape=guide_legend(override.aes=list(fill='black'))) |
| ggsave(filename = 'figure3.png', |
| device = 'png', width = 6, height = 4, units = 'in', dpi = 'print') |