| |
| |
| |
|
|
| rm(list = ls()) |
|
|
| require(foreign) |
| require(ggplot2) |
| require(rgdal) |
| require(rgeos) |
| require(RColorBrewer) |
| require(maptools) |
| require(scales) |
| require(gridExtra) |
| require(plyr) |
| require(dplyr) |
| require(mapproj) |
| require(raster) |
| require(ggvis) |
| require(rdrobust) |
| require(stringdist) |
| require(gdata) |
| require(rdd) |
| require(stargazer) |
| require(ggrepel) |
|
|
| |
|
|
| |
|
|
| string_match <- function(string_to_match, options, smethod="osa") { |
| if(string_to_match!="") { |
| sdists <- stringdist(string_to_match, options, method=smethod) |
| ind <- which(sdists == min(sdists)) |
| if(length(ind) != 1) { |
| ind <- ind[1] |
| } |
| return(options[ind]) |
| } else { |
| return("") |
| } |
| } |
|
|
| as.numeric.factor <- function(x) {as.numeric(levels(x))[x]} |
|
|
| |
|
|
| |
|
|
| |
| latam_path <- "./Data/GIS_LatinAmerica/" |
|
|
| |
| LatAm <- readOGR(latam_path, "LatinAmerica") |
|
|
| |
|
|
| |
| LatAm$CHG_LAND_GINI <- 0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Mexico"] <- -30.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="French Guiana"] <- 0.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Guyana"] <- 0.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Suriname"] <- 0.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Venezuela"] <- -5.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Argentina"] <- 2.5 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Bolivia"] <- -20.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Brazil"] <- 2.5 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Chile"] <- -10.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Ecuador"] <- -5.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Paraguay"] <- 5.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Peru"] <- -15.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Uruguay"] <- 0.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Guatemala"] <- 0.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Belize"] <- 0.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Colombia"] <- -5.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Costa Rica"] <- 0.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="El Salvador"] <- -10.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Honduras"] <- -5.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Nicaragua"] <- -25.0 |
| LatAm$CHG_LAND_GINI[LatAm$CNTRY_NAME=="Panama"] <- 5.0 |
|
|
| |
|
|
| |
| LatAm$coop_land_reform <- 0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Mexico"] <- 1 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="French Guiana"] <- 0.0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Guyana"] <- 0.0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Suriname"] <- 0.0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Venezuela"] <- 1 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Argentina"] <- 0.0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Bolivia"] <- 1 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Brazil"] <- 0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Chile"] <- 1 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Ecuador"] <- 0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Paraguay"] <- 0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Peru"] <- 1 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Uruguay"] <- 0.0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Guatemala"] <- 0.0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Belize"] <- 0.0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Colombia"] <- 1 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Costa Rica"] <- 1 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="El Salvador"] <- 1 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Honduras"] <- 1.0 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Nicaragua"] <- 1 |
| LatAm$coop_land_reform[LatAm$CNTRY_NAME=="Panama"] <- 1.0 |
|
|
|
|
| |
|
|
| |
|
|
| |
| aesthetics <- list( |
| |
| |
| |
| coord_equal(), |
| theme_bw(), |
| theme( |
| |
| |
| text=element_text(family="Palatino"), |
| panel.border = element_blank(), |
| panel.grid.minor=element_blank(), |
| panel.grid.major=element_blank(), |
| axis.title.x=element_blank(), |
| axis.title.y=element_blank(), |
| axis.text=element_blank(), |
| axis.ticks=element_blank())) |
|
|
| |
| LatAm.df <- fortify(LatAm, region="FIPS_CNTRY") |
| LatAm@data$id <- LatAm@data$FIPS_CNTRY |
|
|
| |
| LatAm.df <- join(LatAm.df, LatAm@data, by="id") |
|
|
| |
|
|
|
|
| |
| ES <- LatAm[LatAm$CNTRY_NAME=="El Salvador",] |
| ES@data <- mutate(ES@data, ES = ifelse(CNTRY_NAME=="El Salvador",1,0), ES2 = ifelse(FIPS_CNTRY=="ES",1,0)) |
| |
| ES.df <- fortify(ES, region="FIPS_CNTRY") |
| ES@data$id <- ES@data$FIPS_CNTRY |
|
|
| |
| ES.df <- join(ES.df, ES@data, by="id") |
|
|
| LatAm.ggplot.reform <- geom_polygon(aes(x=long,y=lat, group=group, fill=(coop_land_reform)),data=LatAm.df,size=0.25,col="black") |
|
|
| pdf(file="./Output/LatAm_LRCoops.pdf", height=7, width=7, paper = "letter") |
| print(ggplot(aes(x=long,y=lat, group=group, fill=(coop_land_reform)),data=LatAm.df) + LatAm.ggplot.reform + coord_equal() + aesthetics |
| + scale_fill_distiller(name="Experienced a Land Reform\nthat created Agricultural \nCooperatives, 1920-1990", palette = "Blues", trans = "reverse", breaks = pretty_breaks(n = 1), labels=c("No","Yes"),guide = guide_legend(reverse=TRUE)) |
| + labs(x="Longitude",y="Latitude")) |
| dev.off() |
|
|
| |
| EScentroid.df <- as.data.frame(coordinates(ES)) |
| names(EScentroid.df) <- c("long", "lat") |
| EScentroid.df$CNTRY_NAME <- ES@data$CNTRY_NAME |
| ES.ggplot2 <- geom_polygon(aes(x=long,y=lat, group=group),data=ES.df,col="red",size=0.25, fill=NA,show.legend=FALSE) |
|
|
| pdf(file="./Output/LatAm_LRCoops_wESLabel2.pdf", height=7, width=7, paper = "letter") |
| print(ggplot() |
| + geom_text_repel( data=EScentroid.df, aes(x=long, y=lat, label=CNTRY_NAME), col="red",size=4,nudge_x=-15, nudge_y=-5) |
| + LatAm.ggplot.reform + coord_equal() + aesthetics |
| + ES.ggplot2 |
| + scale_fill_distiller(name="Experienced a Land Reform\nthat created Agricultural\nCooperatives - 1920-1990", palette = "Blues", trans = "reverse", breaks = pretty_breaks(n = 1), labels=c("No","Yes"),guide = guide_legend(reverse=TRUE)) |
| + labs(x="Longitude",y="Latitude")) |
| dev.off() |
|
|
|
|