prepare_df_plot: Generic Function to Prepare TB Burden Data for Plotting

Description Usage Arguments Value See Also Examples

View source: R/prepare_df_plot.R

Description

This function is used internally by plot_tb_burden and plot_tb_burden_overview to prepare data for plotting.

Usage

1
2
3
4
5
6
prepare_df_plot(df = NULL, dict = NULL, metric = "e_inc_100k",
  conf = NULL, metric_label = NULL, countries = NULL, years = NULL,
  compare_to_region = FALSE, facet = NULL, annual_change = FALSE,
  trans = "identity", download_data = TRUE, save = TRUE,
  burden_save_name = "TB_burden", dict_save_name = "TB_data_dict",
  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

conf

Character vector specifying the name variations to use to specify the upper and lower confidence intervals. Defaults to NULL for which no confidence intervals are used. Used by annual_change.

metric_label

Character string specifying the metric label to use.

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.

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.

verbose

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

...

Additional parameters to pass to get_tb_burden.

Value

A list containing 3 elements, the dataframe to plot, the facet to use and the label to assign to the metric axis.

See Also

plot_tb_burden plot_tb_burden_overview

Examples

1
prepare_df_plot(countries = "Guinea")

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