Skip to content

Commit b67328e

Browse files
committed
Initial commit
0 parents  commit b67328e

26 files changed

+412
-0
lines changed

.DS_Store

8 KB
Binary file not shown.

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
^.*\.Rproj$
2+
^\.Rproj\.user$

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.Rproj.user
2+
.Rhistory
3+
.RData

DESCRIPTION

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Package: fetchdhs
2+
Title: Retrieve DHS API Data
3+
Version: 0.1.0
4+
Authors@R: person("Padraic", "Murphy", email = "[email protected]", role = c("aut", "cre"))
5+
Description: A suite of convenience functions to retrieve survey data from the DHS API.
6+
Depends: R (>= 3.4.1)
7+
License: MIT + file LICENCE
8+
Encoding: UTF-8
9+
LazyData: true
10+
RoxygenNote: 6.0.1
11+
Imports: dplyr,
12+
glue,
13+
jsonlite,
14+
purrr,
15+
stringr,
16+
snakecase,
17+
magrittr,
18+
httr,
19+
attempt

LICENCE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
YEAR: 2017
2+
COPYRIGHT HOLDER: PADRAIC MURPHY

NAMESPACE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(fetch_citation)
4+
export(fetch_countries)
5+
export(fetch_data)
6+
export(fetch_indicators)
7+
export(fetch_surveys)
8+
export(fetch_tags)
9+
export(set_api_key)
10+
export(set_return_fields)
11+
importFrom(magrittr,"%<>%")
12+
importFrom(magrittr,"%>%")

R/.DS_Store

6 KB
Binary file not shown.

R/.Rapp.history

Whitespace-only changes.

R/fetch_citation.R

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#' Fetch citation
2+
#'
3+
#' \code{fetch_citation} returns a DHS API citation.
4+
#' @importFrom magrittr %>%
5+
#' @export
6+
fetch_citation <- function() {
7+
jsonlite::fromJSON("https://api.dhsprogram.com/rest/dhs/info/citation") %>%
8+
.$Data %>%
9+
.$Value
10+
}

R/fetch_countries.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#' Fetch country listing
2+
#'
3+
#' \code{fetch_countries} returns a dataframe of all countries with available DHS survey data and their associated DHS and ISO codes.
4+
#' @seealso \code{\link{fetch_data}}
5+
#' @importFrom magrittr %>%
6+
#' @export
7+
fetch_countries <- function() {
8+
jsonlite::fromJSON("https://api.dhsprogram.com/rest/dhs/countries?returnFields=CountryName,DHS_CountryCode,iso3_CountryCode") %>%
9+
.$Data %>%
10+
dplyr::rename_all(snakecase::to_snake_case) %>%
11+
dplyr::as_data_frame()
12+
}

0 commit comments

Comments
 (0)