This general purpose function can be used to generate a global map for a single variable. It has few defaults but the data supplied must contain a country_code variable (that uses the iso3 standard) for linking to mapping data.

global_map(data = NULL, variable = NULL, variable_label = NULL,
  trans = "identity", fill_labels = NULL,
  viridis_palette = "cividis", show_caption = TRUE)

Arguments

data

Dataframe containing variables to be mapped. Must contain a country_code variable. This must use iso3 standard country codes. See link_data for an example dataframe.

variable

A character string indicating the variable to map data for. This must be supplied.

variable_label

A character string indicating the variable label to use. If not supplied then the underlying variable name is used.

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.

fill_labels

A function to use to allocate legend labels. An example (used below) is scales::percent, which can be used for percentage data.

viridis_palette

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

show_caption

Logical, defaults to TRUE. Should the default caption be displayed.

Value

A ggplot2 object containing a global map.

See also

link_data

Examples

## Filter data to get the latest study in each country on zTB data <- EstZoonoticTB::link_data(verbose = FALSE) %>% EstZoonoticTB::get_latest_data(tb_z_prop) ## Plot a global map of zTB global_map(data, variable = "tb_z_prop", variable_label = "% of TB cases that are zoonotic", trans = "sqrt", fill_labels = scales::percent)