Skip to content

Commit

Permalink
update Coppedge -- integrate download and tidyverse clean-up
Browse files Browse the repository at this point in the history
 * download of Google Drive table in main R script
 * tidyverse style guide -- '' --> ""
  • Loading branch information
hdigital committed Jun 15, 2017
1 parent 9457fd0 commit b2727a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
6 changes: 0 additions & 6 deletions import/coppedge/coppedge-google-sheets.R

This file was deleted.

17 changes: 12 additions & 5 deletions import/coppedge/coppedge.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
library("dplyr")
library(tidyverse)

coppedge_raw <- read.csv("coppedge-parties.csv", encoding = "UTF-8", as.is=TRUE)
coppedge_parties <- "coppedge-parties.csv"

if( ! file.exists(coppedge_parties)) {
url <- "https://docs.google.com/spreadsheets/d/1KwaCELyZ4qhVwSYPYl5z_DK2gO_UTmDgfFvxKvHbekk/pub?output=csv"
download.file(url, coppedge_parties, mode="wb")
}

coppedge_raw <- read_csv(coppedge_parties)

# remove duplicates and add first/last year
coppedge <- coppedge_raw %>%
Expand All @@ -13,10 +20,10 @@ coppedge <- coppedge_raw %>%

# filter parties to ignore and short lived parties
coppedge <- coppedge %>%
filter(ignore_partyfacts == 0, year_first != year_last) %>%
filter(ignore_partyfacts == 0, year_first != year_last) %>%
select(-ignore_partyfacts)

# filter Argentina parties more restrictivly
coppedge <- coppedge[ ! with(coppedge, country == 'ARG' & year_last - year_first < 20) , ]
coppedge <- coppedge[ ! with(coppedge, country == "ARG" & year_last - year_first < 20) , ]

write.csv(coppedge, "coppedge.csv", na='', fileEncoding = "utf-8", row.names = FALSE)
write.csv(coppedge, "coppedge.csv", na = "")
5 changes: 4 additions & 1 deletion import/coppedge/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ Working paper no 244. Notre Dame: The Helen Kellogg Institue for International S

http://kellogg.nd.edu/publications/workingpapers/WPS/244.pdf


## Import

pdf converted into spreadsheet -- pdf --> html --> csv

Uploaded to Google Sheets to edit and clean-up Coppedge party list. Import into repository with `coppedge-google-sheet.R` as `coppedge-parties.csv`.
Uploaded to Google Sheets to edit and clean-up Coppedge party list. Import into repository with `coppedge-parties.csv`.


## Comments

Importing only parties with different start and end date. More restrictive import filter for Argentina -- `coppedge.R`


## Todo later

* clean-up of duplicates in Google Sheets (esp. ARG)

0 comments on commit b2727a8

Please sign in to comment.