Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
luizaandrade authored May 6, 2019
2 parents b872c76 + 4e3615b commit 6a09d51
Show file tree
Hide file tree
Showing 24 changed files with 41,706 additions and 471 deletions.
Binary file added DataWork/DataSets/DG1__DS_DIR_HDR
Binary file not shown.
Binary file added DataWork/DataSets/Final/DG1__DS_DIR_HDR
Binary file not shown.
941 changes: 470 additions & 471 deletions DataWork/DataSets/Final/whr_panel.csv

Large diffs are not rendered by default.

Binary file added DataWork/DataSets/Raw/DG1__DS_DIR_HDR
Binary file not shown.
Binary file not shown.
7,351 changes: 7,351 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T02_Pop.csv

Large diffs are not rendered by default.

1,862 changes: 1,862 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T05_parliament.csv

Large diffs are not rendered by default.

8,164 changes: 8,164 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T07_Education.csv

Large diffs are not rendered by default.

4,097 changes: 4,097 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T08_Teachers.csv

Large diffs are not rendered by default.

3,758 changes: 3,758 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T10_Health_Personnel.csv

Large diffs are not rendered by default.

2,226 changes: 2,226 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T11_HealthExpend.csv

Large diffs are not rendered by default.

3,395 changes: 3,395 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T12_Crime.csv

Large diffs are not rendered by default.

1,869 changes: 1,869 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T13_Gdp.csv

Large diffs are not rendered by default.

5,533 changes: 5,533 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T17_Unemployme.csv

Large diffs are not rendered by default.

1,556 changes: 1,556 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/T29_Internet.csv

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions DataWork/DataSets/Raw/UN stats yearbook/draft.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#------------------------------------------------------------------------------#

# UN stats year book data processing

#------------------------------------------------------------------------------#



if (Sys.getenv("USERNAME") == "Leonardo"){
projectFolder <- "C:/Users/Leonardo/Documents/GitHub/dime-r-training"
dropbox <- "C:/Users/Leonardo/Dropbox/Work/WB/R Training/R training"

}

if (Sys.getenv("USERNAME") == "WB519128"){
projectFolder <- file.path("C:/Users/WB519128/Documents/GitHub/dime-r-training")
dropbox <- "C:/Users/WB519128/Dropbox/Work/WB/R Training/R training"

}

UNstatsDat <- file.path(dropbox,"Data/World/Raw/UN stats yearbook")


#------------------------------------------------------------------------------#
#### Load data ####

pop <- read.csv(file.path(UNstatsDat, "T02_Pop.csv"), header = T, stringsAsFactors = F)
int <- read.csv(file.path(UNstatsDat,"T29_Internet.csv"), header = T, stringsAsFactors = F)
crime <- read.csv(file.path(UNstatsDat,"T12_Crime.csv"), header = T, stringsAsFactors = F)
gdp <- read.csv(file.path(UNstatsDat,"T13_Gdp.csv"), header = T, stringsAsFactors = F)
educ <- read.csv(file.path(UNstatsDat,"T07_Education.csv"), header = T, stringsAsFactors = F)
teach <- read.csv(file.path(UNstatsDat,"T08_Teachers.csv"), header = T, stringsAsFactors = F)
med <- read.csv(file.path(UNstatsDat,"T10_Health_Personnel.csv"), header = T, stringsAsFactors = F)

#------------------------------------------------------------------------------#
#### Basic cleaning ####

treat <-
function(x){
names(x) <- c("code",
"country",
"year",
"var",
"value",
"coomments",
"source")

nonCountries <- c("Total, all countries or areas",
"Sub-Saharan Africa",
"Latin America & the Caribbean",
"South-central Asia",
"Australia and New Zealand",
"Oceania",
"Africa",
"Northern Africa",
"Eastern Africa",
"Middle Africa",
"Southern Africa",
"Western Africa",
"Americas",
"Northern America",
"Caribbean",
"Central America",
"South America",
"Asia",
"Central Asia",
"Eastern Asia",
"South-eastern Asia",
"Southern Asia",
"Western Asia",
"Europe",
"Eastern Europe",
"Northern Europe",
"Southern Europe",
"Western Europe",
"Melanesia")

x <- x[!(x$country %in% nonCountries),]
x <- x[x$year > 2014,]
return(x)
}



pop <- treat(pop)
int <- treat(int)
crime <- treat(crime)
gdp <- treat(gdp)
educ <- treat(educ)
teach <-treat(teach)
med <- treat(med)

#------------------------------------------------------------------------------#
#### Population ####

pop$coomments <- NULL
pop$source <- NULL

keepVarspop <- c("Population mid-year estimates (millions)",
"Sex ratio (males per 100 females)")

pop <- pop[pop$var == keepVarspop,]


pop <- spread(pop,
key = var,
value = value)


#names(pop) <-

#------------------------------------------------------------------------------#
#### Population ####


Binary file added DataWork/DataSets/Raw/Un WHR/DG1__DS_DIR_HDR
Binary file not shown.
159 changes: 159 additions & 0 deletions DataWork/DataSets/Raw/Un WHR/WHR2015.csv

Large diffs are not rendered by default.

158 changes: 158 additions & 0 deletions DataWork/DataSets/Raw/Un WHR/WHR2016.csv

Large diffs are not rendered by default.

156 changes: 156 additions & 0 deletions DataWork/DataSets/Raw/Un WHR/WHR2017.csv

Large diffs are not rendered by default.

165 changes: 165 additions & 0 deletions DataWork/DataSets/Raw/Un WHR/country_codes.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
country,code
Norway,578
Denmark,208
Iceland,352
Switzerland,756
Finland,246
Netherlands,528
Canada,124
New Zealand,554
Sweden,752
Australia,36
Israel,376
Costa Rica,188
Austria,40
United States,840
Ireland,372
Germany,276
Belgium,56
Luxembourg,442
United Kingdom,826
Chile,152
United Arab Emirates,784
Brazil,76
Czech Republic,203
Argentina,32
Mexico,484
Singapore,702
Malta,470
Uruguay,858
Guatemala,320
Panama,591
France,250
Thailand,764
Taiwan,158
Spain,724
Qatar,634
Colombia,170
Saudi Arabia,682
Trinidad and Tobago,780
Kuwait,414
Slovakia,703
Bahrain,48
Malaysia,458
Nicaragua,558
Ecuador,218
El Salvador,222
Poland,616
Uzbekistan,860
Italy,380
Russia,643
Belize,84
Japan,392
Lithuania,440
Algeria,12
Latvia,428
South Korea,410
Moldova,498
Romania,642
Bolivia,68
Turkmenistan,795
Kazakhstan,398
North Cyprus,196
Slovenia,705
Peru,604
Mauritius,480
Cyprus,196
Estonia,233
Belarus,112
Libya,434
Turkey,792
Paraguay,600
Hong Kong,344
Philippines,608
Serbia,688
Jordan,400
Hungary,348
Jamaica,388
Croatia,191
Kosovo,
China,156
Pakistan,586
Indonesia,360
Venezuela,862
Montenegro,499
Morocco,504
Azerbaijan,31
Dominican Republic,214
Greece,300
Lebanon,422
Portugal,620
Bosnia and Herzegovina,70
Honduras,340
Macedonia,807
Somalia,706
Vietnam,704
Nigeria,566
Tajikistan,762
Bhutan,64
Kyrgyzstan,417
Nepal,524
Mongolia,496
South Africa,710
Tunisia,788
Palestinian Territories,275
Egypt,818
Bulgaria,100
Sierra Leone,694
Cameroon,120
Iran,364
Albania,8
Bangladesh,50
Namibia,516
Kenya,404
Mozambique,508
Myanmar,104
Senegal,686
Zambia,894
Iraq,368
Gabon,266
Ethiopia,231
Sri Lanka,144
Armenia,51
India,356
Mauritania,478
Congo (Brazzaville),178
Georgia,268
Congo (Kinshasa),180
Mali,466
Ivory Coast,384
Cambodia,116
Sudan,729
Ghana,288
Ukraine,804
Uganda,800
Burkina Faso,854
Niger,562
Malawi,454
Chad,148
Zimbabwe,716
Lesotho,426
Angola,24
Afghanistan,4
Botswana,72
Benin,204
Madagascar,450
Haiti,332
Yemen,887
South Sudan,728
Liberia,430
Guinea,324
Togo,768
Rwanda,646
Syria,760
Tanzania,834
Burundi,108
Central African Republic,140
Puerto Rico,630
Suriname,740
Somaliland Region,
Laos,418
Comoros,174
Oman,512
Somaliland region,
Swaziland,748
Djibouti,262
Loading

0 comments on commit 6a09d51

Please sign in to comment.