Learn R Programming

ggplayfair (version 0.1.1)

StatBalanceOfTrade: StatBalanceOfTrade

Description

Splits a time series of exports and imports into segments of trade surplus or deficit, inserting interpolated intersection points where they cross. This allows ribbons to be shaded differently for surplus vs deficit in a balance of trade plot.

Usage

StatBalanceOfTrade

Arguments

Value

A data.frame with columns: x, ymin, ymax, direction, and group. These are passed to a GeomRibbon layer to visualize the balance of trade.

Format

An object of class StatBalanceOfTrade (inherits from Stat, ggproto, gg) of length 4.

Details

A ggplot2::Stat that computes ribbon boundaries for trade balance visualization. It takes export and import values and generates ymin/ymax pairs for plotting shaded ribbons showing surplus or deficit. Used internally by geom_balance_of_trade().

See Also

geom_balance_of_trade()