Plot the distribution (density) of a single indicator using WDI data, downloading the data as necessary for the period indicated by start and end, and keeping only the latest data point available for each country

plot_dist_wdi(
  indicator = "NY.GDP.PCAP.KD",
  highlight_countries = c("Colombia", "Germany"),
  facets = region,
  start = lubridate::year(Sys.Date()) - 10,
  end = lubridate::year(Sys.Date() - months(18)),
  country = "all",
  regions = default_regions(),
  income_groups = default_income_groups(),
  p = 1
)

Arguments

indicator

character of length 1 with the indicator code

highlight_countries

character vector with country names to highlight

facets

whether to show facets per region or income

start

first year to download data

end

last year to download data

country

subset of countries to download data from. Default to "all". This argument is passed as is to WDI::WDI and hence, requires 'ISO-2 character codes, e.g. "BR", "US", "CA"'.

regions

character vector to filter the data only to specific regions

income_groups

character vector to filter the data only to specific income groups

p

Transformation exponent, <U+03BB>, as in scales::modulus_trans

Value

a ggplot2 object

Examples

if (FALSE) {
plot_dist_wdi()
}