plot_tb_burden: Plot TB Burden by Country

Description Usage Arguments Value See Also Examples

View source: R/plot_tb_burden.R

Description

Plot measures of TB burden by country by specifying a metric from the TB burden data. Specify a country or vector of countries in order to plot them (by default plots all countries). Various other options are available for tuning the plot further.

Usage

1
2
3
4
5
6
7
8
plot_tb_burden(df = NULL, dict = NULL, metric = "e_inc_100k",
  metric_label = NULL, conf = c("_lo", "_hi"), countries = NULL,
  years = NULL, compare_to_region = FALSE, facet = NULL,
  annual_change = FALSE, trans = "identity", scales = "fixed",
  interactive = FALSE, download_data = TRUE, save = TRUE,
  burden_save_name = "TB_burden", dict_save_name = "TB_data_dict",
  viridis_palette = "viridis", viridis_direction = -1,
  viridis_end = 0.9, verbose = TRUE, ...)

Arguments

df

Dataframe of TB burden data, as sourced by get_tb_burden. If not specified then will source the WHO TB burden data, either locally if available or directly from the WHO (if download_data = TRUE).

dict

A tibble of the data dictionary. See get_data_dict for details. If not supplied the function will attempt to load a saved version of the dictionary. If this fails and download_data = TRUE then the dictionary will be downloaded.

metric

Character string specifying the metric to plot

metric_label

Character string specifying the metric label to use.

conf

Character vector specifying the name variations to use to specify the upper and lower confidence intervals. Defaults to c("_lo", "_hi"), if set to NULL then no confidence intervals are shown. When annual_change = TRUE the confidence intervals represent the annual percentage change in the metrics confidence intervals.

countries

A character string specifying the countries to plot.

years

Numeric vector of years. Defaults to NULL which includes all years in the data.

compare_to_region

Logical, defaults to FALSE. If TRUE all countries that share a region with those listed in countries will be plotted. Note that this will override settings for facet, unless it is set to "country".

facet

Character string, the name of the variable to facet by.

annual_change

Logical, defaults to FALSE. If TRUE then the percentage annual change is computed for the specified metric.

trans

A character string specifying the transform to use on the specified metric. Defaults to no transform ("identity"). Other options include log scaling ("log") and log base 10 scaling ("log10"). For a complete list of options see ggplot2::continous_scale.

scales

Character string, see ?ggplot2::facet_wrap for details. Defaults to "fixed", alternatives are "free_y", "free_x", or "free".

interactive

Logical, defaults to FALSE. If TRUE then an interactive plot is returned.

download_data

Logical, defaults to TRUE. If not found locally should the data be downloaded from the specified URL?

save

Logical, should the data be saved for reuse during the current R session. Defaults to TRUE. If TRUE then the data is saved to the temporary directory specified by tempdir.

burden_save_name

Character string, name to save the data under. Defaults to "TB_burden".

dict_save_name

Character string, name to save dictionary under. Defaults to TB_data_dict.

viridis_palette

Character string indicating the viridis colour palette to use. Defaults to "viridis". Options include "cividis", "magma", "inferno", "plasma", and "viridis". For additional details see viridis_pal for additional details.

viridis_direction

Numeric, indicating the direction for the colour palette (1 or -1), defaults to -1. See scale_color_viridis for additional details.

viridis_end

Numeric between 0 and 1, defaults to 0.9. The end point of the viridis scale to use. #' See scale_color_viridis for additional details.

verbose

Logical, defaults to TRUE. Should additional status and progress messages be displayed.

...

Additional parameters to pass to get_tb_burden.

Value

A plot of TB Incidence Rates by Country

See Also

get_tb_burden search_data_dict

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Get the WHO TB burden data and the data dictionary
tb_burden <- get_tb_burden()
dict <- get_data_dict()

## Get a random sample of 9 countries
sample_countries <- sample(unique(tb_burden$country), 9)

## Plot incidence rates in these countries
plot_tb_burden(df = tb_burden, dict = dict, facet = "country", countries = sample_countries)
## Not run: 
## Use data caching to plot incidence rates with free y scales
plot_tb_burden(facet = "country", countries = sample_countries, scales = "free_y")
 
## Plot annual percentage change in incidence rates in selected countries
plot_tb_burden(df = tb_burden, dict = dict, facet = "country", scales = "free_y", 
               countries = sample_countries, annual_change = TRUE, conf = NULL)
               
## Find variables relating to mortality in the WHO dataset
search_data_dict(def = "mortality")
## Plot mortality rates (exc HIV) - without progress messages
plot_tb_burden(metric = "e_mort_exc_tbhiv_100k", facet = "country", 
               countries = sample_countries, scales = "free_y", verbose = FALSE)

## End(Not run)  

getTBinR documentation built on Nov. 16, 2018, 1:17 a.m.