forked from dean-breed/IATI-Covid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ng_qb2.R
37 lines (30 loc) · 954 Bytes
/
ng_qb2.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
list.of.packages <- c("data.table", "anytime", "dplyr", "reshape2","splitstackshape","stringr", "readr")
new.packages <- list.of.packages[!(list.of.packages %in% installed.packages()[,"Package"])]
if(length(new.packages)) install.packages(new.packages)
lapply(list.of.packages, require, character.only=T)
wd = "/home/alex/git/IATI-Covid/output/"
setwd(wd)
recipient_country = "NG"
# 1. Activities filtered by activity-level recipient country
url = paste0(
"https://iatidatastore.iatistandard.org/search/activity?q=recipient_country_code:(",
recipient_country,
")&wt=xslt&tr=activity-csv.xsl&rows=1000000"
)
afa_filename = paste0(recipient_country,"_activity_filtered_activities.csv")
if(!file.exists(afa_filename)){
data_file = download.file(
url,
destfile=afa_filename
)
}
afa <- read.table(
afa_filename,
header=T,
sep=",",
quote=c("\""),
na.strings="",
stringsAsFactors=FALSE,
flush=T
)
# 2. Split by transaction