[Questioning] 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 variable for linking to mapping data. This function requires the installation of the rnaturalearth package. Status of this function is currently questioning as it is uncertain if it is in use. Future releases may depreciate it.

  data = NULL,
  variable = NULL,
  variable_label = NULL,
  trans = "identity",
  fill_labels = NULL,
  scale_fill = NULL,



Dataframe containing variables to be mapped. Must contain a country variable.


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


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


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.


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


Function to use for scaling the fill. Defaults to a custom ggplot2::scale_fill_manual, which expects the possible values to be "Increasing", "Likely increasing", "Likely decreasing", "Decreasing" or "Stable".


Additional arguments passed to the scale_fill function


A ggplot2 object containing a global map.


# \donttest{
if (requireNamespace("rnaturalearth") & requireNamespace("scales")) {
  # Example 1 - categorical data
  # If values are "Increasing", "Likely increasing" etc (see ?EpiNow2::theme_map),
  # then the default fill scale works
  eg_data <- data.table::data.table(
    variable = c(
      "Likely decreasing",
      "Likely increasing"
    country = c(
      "United Kingdom",
  # make variable a factor so the ordering is sensible in the legend
  eg_data$variable <- factor(eg_data$variable, levels = c(
    "Decreasing", "Likely decreasing",
    "Stable", "Likely increasing",
  global_map(eg_data, variable = "variable", variable_label = "Direction\nof change")

  # Example 2 - numeric data
  # numeric data requires scale_fill and a global viridis_palette specified
  eg_data$second_variable <- runif(nrow(eg_data))
  viridis_palette <- "A"
  global_map(eg_data, variable = "second_variable", scale_fill = scale_fill_viridis_c)
#> The rnaturalearthdata package needs to be installed.
#> Installing the rnaturalearthdata package.
#> Installing package into ‘/Users/runner/work/_temp/Library’
#> (as ‘lib’ is unspecified)
#> Error in value[[3L]](cond): Failed to install the rnaturalearthdata package.
#>  Please try installing the package for yourself using the following command: 
#>  install.packages("rnaturalearthdata")
# }