Plot summaries of TB burden metrics by region, globally, and for custom groupings. For variables with uncertainty represented by confidence intervals bootstrapping can be used (assuming a normal distribution) to include this in any estimated summary measures. Currently four statistics are supported; the mean (with 95\
plot_tb_burden_summary(
df = NULL,
dict = NULL,
metric = "e_inc_num",
metric_label = NULL,
conf = c("_lo", "_hi"),
years = NULL,
samples = 1000,
countries = NULL,
compare_to_region = FALSE,
compare_to_world = TRUE,
custom_compare = NULL,
compare_all_regions = TRUE,
stat = "rate",
denom = "e_pop_num",
rate_scale = 1e+05,
truncate_at_zero = TRUE,
annual_change = FALSE,
smooth = FALSE,
facet = NULL,
legend = "bottom",
trans = "identity",
scales = "fixed",
interactive = FALSE,
viridis_palette = "viridis",
viridis_direction = -1,
viridis_end = 0.9,
download_data = TRUE,
save = TRUE,
verbose = FALSE,
...
)
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
).
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.
Character string specifying the metric to plot
Character string defaulting to NULL
. If supplied this metric will be looked up
using the WHO data dictionary to provide a label. A use case would be when calculating incidence rates using e_inc_100k
to get the WHO TB incidence rate label.
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.
Numeric vector of years. Defaults to NULL
which includes all years in the data.
Numeric, the number of samples to use to generate confidence
intervals (only used when conf
are present)
A character string specifying the countries to target.
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".
Logical, defaults to TRUE
. Should a comparison be made to
the metric of interests global value.
Logical, defaults to NULL
. A named list of custom countries.
Logical, defaults to TRUE
. Should all regions be compared.
Character string, defaults to "rate"
. The statistic to use to summarise the metric, currently
"mean"
, "median"
, "rate"
and "prop"
are supported. Note "mean" and "median" do not recompute the supplied
country levels values but can be used to summarise the distribution of region or global metrics. "prop"
and"rate"
compute the overall incidence rate for a given grouping (i.e the sum of the metric divided by the sum of the denominator).
Character string defaulting to e_pop_num
(country level population). If stat
is set to rate
or
prop
then this is the parameter to use as the denominator.
Numeric defaults to 100,000. The scaling to use for rates. If stat
is to set to prop
then this defaults
to 1.
Logical, defaults to TRUE
. Should lower bounds be truncated at zero?
Logical, defaults to FALSE
. If TRUE
then the
percentage annual change is computed for the specified metric.
Logical, defaults to FALSE
. Should the data be smoothed (using ggplot2::geom_smooth
)
prior to plotting. If set to TRUE
then the confidence intervals shown are derived from the smooth
and do not represent the underlying uncertainty in the data.
Character string, the name of the variable to facet by.
Character string, defaults to "top"
. Position of the legend see ?ggplot2::theme
for defaults but known
options are: "none"
, "top"
, "right"
and "bottom"
.
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
.
Character string, see ?ggplot2::facet_wrap for details. Defaults to "fixed", alternatives are "free_y", "free_x", or "free".
Logical, defaults to FALSE
. If TRUE
then an interactive plot is
returned.
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.
Numeric, indicating the direction for the colour palette (1 or -1), defaults to -1.
See scale_color_viridis
for additional details.
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.
Logical, defaults to TRUE
. If not found locally should the data be
downloaded from the specified URL?
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
.
Logical, defaults to FALSE
. Should additional status and progress messages
be displayed.
Additional arguments to pass to get_tb_burden
.
A plot of TB Incidence Rates by Country
search_data_dict plot_tb_burden summarise_tb_burden
summarise_tb_burden get_tb_burden search_data_dict
# NOT RUN {
## Get an overview of incidence rates regionally and globally compared to the UK
plot_tb_burden_summary(
metric = "e_inc_num",
metric_label = "e_inc_100k",
stat = "rate",
countries = "United Kingdom",
compare_to_world = TRUE,
compare_all_regions = TRUE,
verbose = FALSE,
scales = "free_y",
facet = "Area"
)
# }
# NOT RUN {
## Get summary data for the UK, Europe and the world
## Bootstrapping CI's
plot_tb_burden_summary(
metric = "e_inc_num",
samples = 100,
stat = "mean",
countries = "United Kingdom",
compare_to_world = TRUE,
compare_to_region = TRUE,
verbose = FALSE,
facet = "Area",
scales = "free_y"
)
# }
Run the code above in your browser using DataLab