Jason Pickering
August 6, 2017
setwd
to match the location of the GitHub repo on your machine.baseurl
to point to where your installation of DHIS2 is running.username
and district
to suit your DHIS2 installation.setwd("/home/jason/development/dhis2-data-munging/")
baseurl<-"http://localhost:8080/dhis/"
username<-"admin"
password<-"district"
## [1] TRUE
http://aidsinfo.unaids.org/
site and parse this data into a data frame.All ages estimate | All ages lower estimate | All ages upper estimate | country | year |
---|---|---|---|---|
369.55116 | 142.92316 | 745.52936 | Afghanistan | 1990 |
483.6869 | 205.20409 | 965.83533 | Afghanistan | 1991 |
622.1754 | 264.81107 | 1203.39917 | Afghanistan | 1992 |
778.90703 | 357.96414 | 1485.74292 | Afghanistan | 1993 |
944.91716 | 449.15015 | 1733.13586 | Afghanistan | 1994 |
1105.99481 | 555.44891 | 2007.5 | Afghanistan | 1995 |
d<-d_all[,c("All ages estimate","country","year")]
names(d)<-c("value","orgUnit","period")
d<-d[!is.na(d$value),]
d$value<-round(as.numeric(d$value))
## Warning: NAs introduced by coercion
knitr::kable(head(d))
value | orgUnit | period |
---|---|---|
370 | Afghanistan | 1990 |
484 | Afghanistan | 1991 |
622 | Afghanistan | 1992 |
779 | Afghanistan | 1993 |
945 | Afghanistan | 1994 |
1106 | Afghanistan | 1995 |
Convert the country names in the data file back to a character (instead of a factor) so that we can use this column to join the OU listing from DHIS2 with it.
This will keep all of the countries, even if there is not a match from DHIS2.
## [1] "Bolivia (Plurinational State of)"
## [2] "Cabo Verde"
## [3] "Côte d'Ivoire"
## [4] "Democratic People's Republic of Korea"
## [5] "Myanmar"
## [6] "Republic of Korea"
## [7] "Russian Federation"
## [8] "South Sudan"
## [9] "Venezuela (Bolivarian Republic of)"
from | to |
---|---|
Bolivia (Plurinational State of) | Bolivia |
Cabo Verde | Cape Verde |
Côte d’Ivoire | Cote d’Ivoire |
Democratic People’s Republic of Korea | Korea, Democratic People’s Republic of |
Myanmar | Burma |
Republic of Korea | Korea, Republic of |
Russian Federation | Russia |
South Sudan | South Sudan |
Venezuela (Bolivarian Republic of) | Venezuela |
## Warning in set.seed(38894): '.Random.seed' is not an integer vector but of
## type 'NULL', so ignored