Skip to contents

Plots the top_n countries with the largest value of one indicator as horizontal bars, animated over Year (a "bar chart race"), for the Barplot tab: in every frame the bars are ranked again, so a country that overtakes another moves up. A country's missing years between two observed ones are filled by linear interpolation, so that it does not drop out of the race for a year and come back; nothing is filled before its first or after its last observed year. Each bar carries the country name and its value, to 3 significant digits (1.52k, 6.02M); the bar of country is red, so that it can be followed through the race, and the year of the frame is printed large and gray in the bottom right corner. Only rows with a positive value are used.

Usage

plot_bar(mfi, indicator, font_style, top_n = 20, country = NULL)

Arguments

mfi

Data frame of World Bank indicator values (long format, with Country Name, Indicator Name, Year, value columns).

indicator

Character. Indicator name to plot.

font_style

A plotly font list for the layout of the chart; the app passes font_style.

top_n

Integer. Number of countries shown in each year.

country

Character. Country whose bar is drawn red (NULL for none).

Value

A plotly htmlwidget, or NULL when the indicator has fewer than two positive values.

Examples

plot_bar(mfi, indicator = "GDP (current US$)", font_style = font_style, country = "Greece")