Skip to content

Commit 2edef21

Browse files
author
weste
committed
scripts for TB done. No issues with data imports. Excludes R4DS textbook
1 parent 873f71e commit 2edef21

File tree

6 files changed

+112
-0
lines changed

6 files changed

+112
-0
lines changed

data_scripts/tuberculosis/budget.R

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library(tidyverse)
2+
3+
4+
tb_budget <- read_csv("https://extranet.who.int/tme/generateCSV.asp?ds=budget")
5+
6+
# Data details
7+
dpr_document(tb_budget, extension = ".md.R", export_folder = usethis::proj_get(),
8+
object_name = "tb_budget",
9+
title = "Word Health Organization (WHO) Tuberculosis budgets by country",
10+
description = "See source for description of the data. tb_dictionary describes the column names.",
11+
source = "https://www.who.int/tb/country/data/download/en/",
12+
var_details = list(nothing = "nothing"))

data_scripts/tuberculosis/cases.R

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
library(tidyverse)
2+
3+
4+
tb_cases <- read_csv("https://extranet.who.int/tme/generateCSV.asp?ds=notifications")
5+
6+
# Wrangling
7+
cases_clean <- tb_cases %>%
8+
select(-(new_sp:c_newinc),
9+
-contains('_fu'), -contains('_mu'), -contains('_sexunk'),
10+
-contains('gesex'), -contains('15plus'), -contains('014'),
11+
-(rdx_data_available:hiv_reg_new2)) %>%
12+
pivot_longer(
13+
cols = new_sp_m04:newrel_f65,
14+
names_to = "key",
15+
values_to = "cases",
16+
values_drop_na = TRUE
17+
) %>%
18+
mutate(
19+
key = stringr::str_replace(key, "newrel", "new_rel")
20+
) %>%
21+
separate(key, c("new", "var", "sexage")) %>%
22+
select(-new, -iso2, -iso3, -iso_numeric) %>%
23+
separate(sexage, c("sex", "age"), sep = 1) %>%
24+
mutate(
25+
age_middle = case_when(
26+
age == '04' ~ 2,
27+
age == '514' ~ 9,
28+
age == '1524' ~ 19,
29+
age == '2534' ~ 29,
30+
age == '3544' ~ 39,
31+
age == '4554' ~ 49,
32+
age == '5564' ~ 59,
33+
age == '65' ~ 75),
34+
var = case_when(
35+
var == 'sp' ~ 'smear positive',
36+
var == 'sn' ~ 'smear negative',
37+
var == 'rel' ~ 'relapse',
38+
var == 'ep' ~ 'extrapulmonary'
39+
)) %>%
40+
select(country, g_whoregion, year, sex, age, age_middle, var, cases)
41+
42+
43+
44+
# Data details
45+
dpr_document(tb_cases, extension = ".md.R", export_folder = usethis::proj_get(),
46+
object_name = "tb_cases",
47+
title = "Word Health Organization (WHO) Tuberculosis case notifications by country",
48+
description = "See source for description of the data. tb_dictionary describes the column names.",
49+
source = "https://www.who.int/tb/country/data/download/en/",
50+
var_details = list(nothing = "nothing"))
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library(tidyverse)
2+
3+
4+
tb_dictionary <- read_csv("https://extranet.who.int/tme/generateCSV.asp?ds=dictionary")
5+
6+
# Data details
7+
dpr_document(tb_dictionary, extension = ".md.R", export_folder = usethis::proj_get(),
8+
object_name = "tb_dictionary",
9+
title = "Word Health Organization (WHO) Tuberculosis csv file column names",
10+
description = "File found at https://extranet.who.int/tme/generateCSV.asp?ds=dictionary",
11+
source = "https://www.who.int/tb/country/data/download/en/",
12+
var_details = list(nothing = "nothing"))

data_scripts/tuberculosis/estimates.R

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
library(tidyverse)
2+
3+
4+
tb_estimates <- read_csv("https://extranet.who.int/tme/generateCSV.asp?ds=estimates")
5+
6+
# Data details
7+
dpr_document(tb_estimates, extension = ".md.R", export_folder = usethis::proj_get(),
8+
object_name = "tb_estimates",
9+
title = "Word Health Organization (WHO) Tuberculosis csv file column names",
10+
description = "File found at https://extranet.who.int/tme/generateCSV.asp?ds=dictionary",
11+
source = "https://www.who.int/tb/country/data/download/en/",
12+
var_details = list(nothing = "nothing"))
13+

data_scripts/tuberculosis/outcomes.R

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
library(tidyverse)
2+
3+
4+
tb_outcomes <- read_csv("https://extranet.who.int/tme/generateCSV.asp?ds=outcomes")
5+
6+
# Data details
7+
dpr_document(tb_outcomes, extension = ".md.R", export_folder = usethis::proj_get(),
8+
object_name = "tb_outcomes",
9+
title = "Word Health Organization (WHO) Tuberculosis treatment outcomes by country",
10+
description = "See source for description of the data. tb_dictionary describes the column names.",
11+
source = "https://www.who.int/tb/country/data/download/en/",
12+
var_details = list(nothing = "nothing"))
13+
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
library(tidyverse)
2+
3+
4+
tb_utilization <- read_csv("https://extranet.who.int/tme/generateCSV.asp?ds=expenditure_utilisation")
5+
6+
# Data details
7+
dpr_document(tb_utilization, extension = ".md.R", export_folder = usethis::proj_get(),
8+
object_name = "tb_utilization",
9+
title = "Word Health Organization (WHO) Tuberculosis expenditures and utilization by country",
10+
description = "See source for description of the data. tb_dictionary describes the column names.",
11+
source = "https://www.who.int/tb/country/data/download/en/",
12+
var_details = list(nothing = "nothing"))

0 commit comments

Comments
 (0)