-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_DHS_data.R
97 lines (72 loc) · 3.71 KB
/
get_DHS_data.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
install_bitbucket(repo = "hansekbrand/iwi")
install_bitbucket(repo = "hansekbrand/DHSharmonisation")
library(globallivingconditions)
library(iwi)
# Test download.and.harmonise (on one wave in Cameroon, assuming DHS data is
# already downloaded).
# getDHSDataQuick()
#Full run:
living_conditions_file_path <- file.path(downloaded_DHS_data_file_path, "global-living-conditions")
setwd(repo_file_path) #reset wd in case of errors -- UPDATE: I no longer use wd since this is brittle
dt <- getDHSData(dhs.user = username,
dhs.password = pass,
log.filename = "living-conditions.log",
cacheFolderPath = NULL,
harmonised.DHS.data.file.path = harmonised_DHS_data_file_path,
vars.to.keep = vars_to_keep,
variable.packages = variable_packages,
superclusters = FALSE,
living.conditions.file.path = living_conditions_file_path,
qog.file.path = qog_file_path,
updateSurveyInfoVars = FALSE,
countries = NULL,
waves = NULL)
setwd(repo_file_path) #reset wd in case of errors
getDHSData(countries = "Senegal", check.dhs.for.more.data = F,
cacheFolderPath = here("cache_220619_092818"),
variable.packages = NULL)
setwd(repo_file_path) #reset wd in case of errors
getDHSData(countries = "Senegal", check.dhs.for.more.data = F,
variable.packages = NULL,
cacheFolderPath = here("cache_Senegal220619_123454"),
make.pdf = T)
setwd(repo_file_path) #reset wd in case of errors
dt <- getDHSData(countries = "Senegal",
check.dhs.for.more.data = F,
variable.packages = NULL,
living.conditions.file.path = living_conditions_minimal_file_path)
#Testing:
dt <- download.and.harmonise(dhs.user= username,
dhs.password= pass,
log.filename="living-conditions.log",
vars.to.keep = vars_to_keep,
variable.packages = variable_packages,
superclusters = F,
directory = living_conditions_file_path,
qog.file.path = qog_file_path,
#countries = "Tanzania", #Try with "Guinea" and get an error
check.dhs.for.more.data = T,
#waves = list("Tanzania" = c("7I")),
make.pdf = F)
dt <- download.and.harmonise(dhs.user= username,
dhs.password= pass,
log.filename="living-conditions.log",
variable.packages = c("wealth"),
superclusters = FALSE,
qog.file.path = paste(normalizePath("~"),
"qog_std_ts_jan22.sav",
sep = "/"),
countries = "Guinea",
check.dhs.for.more.data = F)
str(dt)
dt <- download.and.harmonise(dhs.user= username,
dhs.password= pass,
log.filename="living-conditions.log")
#Calculate the IWI too:
dt <- download.and.harmonise(dhs.user= username,
dhs.password= pass,
log.filename="living-conditions.log",
variable.packages = c("wealth"),
directory = living_conditions_file_path,
superclusters = FALSE,
qog.file.path = qog_file_path)