Word Health Organization (WHO) Tuberculosis treatment outcomes by country

See source for description of the data. tb_dictionary describes the column names.
health
Author

DS 150

Published

February 20, 2024

Data details

There are 5,969 rows and 73 columns. The data source1 is used to create our data that is stored in our pins table. You can access this pin from a connection to posit.byui.edu using hathawayj/tb_outcomes.

This data is available to all.

Variable description

See source for description of the data. tb_dictionary describes the column names.

Variable summary

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
year 0 1.00 2007.56 8.08 1994 2001.00 2008 2015.00 2021 ▇▆▇▇▇
rep_meth 2935 0.51 100.27 0.65 100 100.00 100 100.00 102 ▇▁▁▁▁
new_sp_coh 2917 0.51 10874.19 45628.38 0 127.50 1233 5368.25 642321 ▇▁▁▁▁
new_sp_cur 3024 0.49 7895.22 37514.77 0 66.00 721 3399.00 544731 ▇▁▁▁▁
new_sp_cmplt 3026 0.49 965.71 3325.33 0 13.00 124 585.00 64938 ▇▁▁▁▁
new_sp_died 2977 0.50 431.34 1616.20 0 7.00 60 257.00 27005 ▇▁▁▁▁
new_sp_fail 3093 0.48 184.12 812.66 0 0.00 15 99.00 12505 ▇▁▁▁▁
new_sp_def 3015 0.49 613.54 2387.19 0 5.00 91 394.50 35469 ▇▁▁▁▁
c_new_sp_tsr 2963 0.50 75.76 16.29 0 69.00 79 86.75 100 ▁▁▂▇▇
new_snep_coh 4668 0.22 13658.98 58938.20 0 77.00 758 5061.00 618935 ▇▁▁▁▁
new_snep_cmplt 4680 0.22 11477.01 52324.18 0 53.00 583 3719.00 556497 ▇▁▁▁▁
new_snep_died 4702 0.21 542.78 1889.61 0 5.00 46 286.50 20759 ▇▁▁▁▁
new_snep_fail 4780 0.20 98.24 497.98 0 0.00 1 15.00 6196 ▇▁▁▁▁
new_snep_def 4710 0.21 741.61 3296.50 0 2.00 43 292.00 42847 ▇▁▁▁▁
c_new_snep_tsr 4749 0.20 76.92 18.24 0 70.00 82 89.00 100 ▁▁▁▅▇
ret_coh 3567 0.40 2583.16 16632.66 0 16.25 190 862.00 304431 ▇▁▁▁▁
ret_cur 3628 0.39 1419.77 8825.29 0 6.00 82 384.00 132064 ▇▁▁▁▁
ret_cmplt 3647 0.39 465.01 4269.34 0 3.00 24 123.75 95592 ▇▁▁▁▁
ret_died 3648 0.39 176.65 1149.72 0 2.00 15 61.00 20468 ▇▁▁▁▁
ret_fail 3697 0.38 131.86 766.43 0 0.00 5 32.00 11886 ▇▁▁▁▁
ret_def 3652 0.39 276.94 2239.67 0 1.00 20 91.00 39698 ▇▁▁▁▁
hiv_new_sp_coh 5150 0.14 445.51 2687.81 0 0.00 7 67.50 66254 ▇▁▁▁▁
hiv_new_sp_cur 5198 0.13 292.59 1974.84 0 0.00 2 25.00 48015 ▇▁▁▁▁
hiv_new_sp_cmplt 5202 0.13 57.58 288.05 0 0.00 1 9.00 5208 ▇▁▁▁▁
hiv_new_sp_died 5187 0.13 53.56 254.74 0 0.00 1 15.00 5489 ▇▁▁▁▁
hiv_new_sp_fail 5233 0.12 8.74 53.00 0 0.00 0 1.00 1234 ▇▁▁▁▁
hiv_new_sp_def 5217 0.13 29.31 166.58 0 0.00 0 7.00 3887 ▇▁▁▁▁
hiv_new_snep_coh 5202 0.13 620.60 4592.11 0 0.00 4 50.00 106717 ▇▁▁▁▁
hiv_new_snep_cmplt 5221 0.13 466.32 3522.50 0 0.00 2 28.00 77966 ▇▁▁▁▁
hiv_new_snep_died 5249 0.12 76.61 478.56 0 0.00 0 12.25 11196 ▇▁▁▁▁
hiv_new_snep_fail 5287 0.11 2.99 28.03 0 0.00 0 0.00 691 ▇▁▁▁▁
hiv_new_snep_def 5258 0.12 42.22 300.64 0 0.00 0 4.00 6873 ▇▁▁▁▁
hiv_ret_coh 5237 0.12 181.25 1709.06 0 0.00 0 11.00 40794 ▇▁▁▁▁
hiv_ret_cur 5281 0.12 41.36 395.98 0 0.00 0 4.00 9686 ▇▁▁▁▁
hiv_ret_cmplt 5276 0.12 81.71 825.67 0 0.00 0 2.00 17332 ▇▁▁▁▁
hiv_ret_died 5272 0.12 26.71 221.17 0 0.00 0 3.00 5151 ▇▁▁▁▁
hiv_ret_fail 5294 0.11 4.61 32.64 0 0.00 0 0.00 758 ▇▁▁▁▁
hiv_ret_def 5277 0.12 18.37 170.35 0 0.00 0 2.00 4092 ▇▁▁▁▁
rel_with_new_flg 3994 0.33 0.90 0.30 0 1.00 1 1.00 1 ▁▁▁▁▇
used_2021_defs_flg 5579 0.07 0.82 0.38 0 1.00 1 1.00 1 ▂▁▁▁▇
newrel_coh 3997 0.33 30638.34 140036.20 0 233.25 2335 11131.50 2152563 ▇▁▁▁▁
newrel_succ 4008 0.33 26158.34 117673.03 0 162.00 1816 8797.00 1807299 ▇▁▁▁▁
newrel_fail 4035 0.32 269.63 1311.34 0 0.00 14 110.00 29660 ▇▁▁▁▁
newrel_died 4020 0.33 1217.19 5102.61 0 14.00 124 580.00 88028 ▇▁▁▁▁
newrel_lost 4028 0.33 1278.18 5587.11 0 5.00 106 592.00 76712 ▇▁▁▁▁
c_new_tsr 1033 0.83 76.91 16.29 0 70.00 81 88.00 100 ▁▁▁▆▇
ret_nrel_coh 4123 0.31 1446.15 10566.56 0 2.00 55 380.75 177695 ▇▁▁▁▁
ret_nrel_succ 4146 0.31 1013.56 7626.45 0 1.00 35 261.50 132225 ▇▁▁▁▁
ret_nrel_fail 4152 0.30 43.77 304.69 0 0.00 1 11.00 6868 ▇▁▁▁▁
ret_nrel_died 4152 0.30 98.42 688.52 0 0.00 4 26.00 13737 ▇▁▁▁▁
ret_nrel_lost 4154 0.30 149.72 1064.90 0 0.00 6 44.00 25757 ▇▁▁▁▁
c_ret_tsr 2305 0.61 66.50 19.82 0 55.00 70 79.00 100 ▁▁▃▇▃
tbhiv_coh 4346 0.27 2552.43 12245.74 0 1.00 33 553.00 200012 ▇▁▁▁▁
tbhiv_succ 4379 0.27 1952.19 9529.18 0 1.00 23 378.00 147605 ▇▁▁▁▁
tbhiv_fail 4384 0.27 26.15 147.43 0 0.00 0 6.00 2557 ▇▁▁▁▁
tbhiv_died 4379 0.27 279.50 1152.45 0 0.00 5 76.00 20558 ▇▁▁▁▁
tbhiv_lost 4384 0.27 154.38 812.99 0 0.00 2 37.00 13305 ▇▁▁▁▁
c_tbhiv_tsr 4094 0.31 63.32 24.01 0 50.00 67 79.00 100 ▁▂▅▇▅
mdr_coh 3272 0.45 459.54 2656.42 0 1.00 14 99.00 60858 ▇▁▁▁▁
mdr_succ 3347 0.44 266.69 1475.90 0 0.00 9 65.00 34891 ▇▁▁▁▁
mdr_fail 3429 0.43 40.92 319.38 0 0.00 0 2.00 9260 ▇▁▁▁▁
mdr_died 3379 0.43 69.92 428.47 0 0.00 2 13.00 7985 ▇▁▁▁▁
mdr_lost 3394 0.43 69.64 415.90 0 0.00 1 11.00 8051 ▇▁▁▁▁
xdr_coh 3892 0.35 43.20 349.45 0 0.00 0 2.00 8950 ▇▁▁▁▁
xdr_succ 3990 0.33 20.41 182.26 0 0.00 0 1.00 5726 ▇▁▁▁▁
xdr_fail 4005 0.33 7.03 59.85 0 0.00 0 0.00 1237 ▇▁▁▁▁
xdr_died 4000 0.33 10.06 76.73 0 0.00 0 0.00 1579 ▇▁▁▁▁
xdr_lost 4005 0.33 4.82 37.56 0 0.00 0 0.00 831 ▇▁▁▁▁

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
country 0 1 4 56 0 217 0
iso2 28 1 2 2 0 216 0
iso3 0 1 3 3 0 217 0
iso_numeric 0 1 3 3 0 217 0
g_whoregion 0 1 3 3 0 6 0
Explore generating code using R
library(tidyverse)
library(pins)
library(connectapi)

tb_outcomes <- read_csv("https://extranet.who.int/tme/generateCSV.asp?ds=outcomes")

# Publish the data to the server with Bro. Hathaway as the owner.
board <- board_connect()
pin_write(board, tb_outcomes, type = "parquet")

pin_name <- "tb_outcomes"
meta <- pin_meta(board, paste0("hathawayj/", pin_name))
client <- connect()
my_app <- content_item(client, meta$local$content_id)
set_vanity_url(my_app, paste0("data/", pin_name))

Access data

This data is available to all.

Direct Download: tb_outcomes.parquet

R and Python Download:

URL Connections:

For public data, any user can connect and read the data using pins::board_connect_url() in R.

library(pins)
url_data <- "https://posit.byui.edu/data/tb_outcomes/"
board_url <- board_connect_url(c("dat" = url_data))
dat <- pin_read(board_url, "dat")

Use this custom function in Python to have the data in a Pandas DataFrame.

import pandas as pd
import requests
from io import BytesIO

def read_url_pin(name):
  url = "https://posit.byui.edu/data/" + name + "/" + name + ".parquet"
  response = requests.get(url)
  if response.status_code == 200:
    parquet_content = BytesIO(response.content)
    pandas_dataframe = pd.read_parquet(parquet_content)
    return pandas_dataframe
  else:
    print(f"Failed to retrieve data. Status code: {response.status_code}")
    return None

# Example usage:
pandas_df = read_url_pin("tb_outcomes")

Authenticated Connection:

Our connect server is https://posit.byui.edu which you assign to your CONNECT_SERVER environment variable. You must create an API key and store it in your environment under CONNECT_API_KEY.

Read more about environment variables and the pins package to understand how these environment variables are stored and accessed in R and Python with pins.

library(pins)
board <- board_connect(auth = "auto")
dat <- pin_read(board, "hathawayj/tb_outcomes")
import os
from pins import board_rsconnect
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv('CONNECT_API_KEY')
SERVER = os.getenv('CONNECT_SERVER')

board = board_rsconnect(server_url=SERVER, api_key=API_KEY)
dat = board.pin_read("hathawayj/tb_outcomes")