Skip to contents

Generates the trajectory of each country data series and supports two plot modes: The display of all series uniformly or a mode that highlight countries with metric values within a specified percentile. Each mode can be rendered in two versions: ungrouped and grouped. Hovering over each highlighted line displays the corresponding country name and metric value

Usage

plot_data_trajectories(
  wdi_data,
  index = NULL,
  group_var = NULL,
  metric_summary = NULL,
  metric_var = NULL,
  percentile = 0.95
)

Arguments

wdi_data

A data frame of the indicator data generated by get_wdi_data

index

A character string specifying the indicator code Defaults to NULL

group_var

A grouping variable in the WDI data set (e.g., "region" or "income") Default to NULL If NULL, trajectories are ungrouped and if specified, trajectories are grouped by the levels of the variable

metric_summary

A data frame containing computed diagnostic metrics and the pre-defined grouping information, generated by passing the output of any diagnostic metrics function to add_group_info Defaults to NULL. If NULL, data trajectories are plotted per country series If specified, it highlight countries using a colour palette based on a metric threshold

metric_var

Character string specifying metric variable name in metric_summary to plot

percentile

A percentile threshold (between 0 and 1) for highlighting countries based on their metric values Defaults to 0.95, meaning countries that fall within the top 5% of metric_var values

Value

An ungrouped or grouped interactive plot object displaying the trajectory of country-level data series. It supports both the display of all series uniformly, and also a mode that highlight countries that fall within a specified percentile of any chosen diagnostic metric values.

Examples

pm_diagnostic_metrics <- compute_diagnostic_indices(pm_data, group_var = "region")
pm_diagnostic_metrics_group <- add_group_info(metric_summary = pm_diagnostic_metrics,pm_data)
plot_data_trajectories(pm_data, group_var = "region",
metric_summary = pm_diagnostic_metrics_group, metric_var = "within_group_avg_dist")