Skip to contents

Reshapes mfi from long to wide so indicator1 and indicator2 become plottable x/y columns, joins in Region from country_code, and plots a bubble scatter (bubble size = population, color = region), animated over Year, with play/pause controls. Rows with missing values or no region are dropped before plotting.

Usage

plot_cor(mfi, country_code, indicator1, indicator2, font_style)

Arguments

mfi

Data frame of World Bank indicator values (long format, with Country Name, Indicator Name, Year, value columns). Must also contain a "Population, total" indicator, used for bubble sizing.

country_code

Data frame mapping countries to region, with columns Country Code, Short Name, Region.

indicator1

Character. Indicator name plotted on the x-axis.

indicator2

Character. Indicator name plotted on the y-axis.

font_style

A plotly font list (e.g. list(size = 20, color = "gray25")) applied to the chart's layout.

Value

A plotly htmlwidget.

Examples

plot_cor(
  mfi,
  country_code,
  indicator1 = "Mortality rate, adult, male (per 1,000 male adults)",
  indicator2 = "Mortality rate, infant (per 1,000 live births)",
  font_style = font_style
)