rk.gganimate: Gapminder-style Animations & Data Storytelling for RKWard

rk.gganimate is an advanced RKWard GUI plugin suite that brings the power of gganimate, ggplot2, and srvyr into a point-and-click interface. Designed for data storytelling, it allows researchers to easily aggregate complex survey data (or standard data frames) and render stunning, publication-ready animated GIFs—including Gapminder-style bubble charts, dynamic line charts, and viral Bar Chart Races.


🌟 Key Features


🚀 What's New in Version 0.0.6

This update brings refined Storytelling controls inspired by Storytelling with Data (SWD) principles, along with crucial UI and engine optimizations:


🚀 What's New in Version 0.0.5

This major update expands the plugin suite beyond bubble charts, introducing two highly requested animation formats and advanced storytelling features:

🚀 What's New in Version 0.0.4

This major update transforms the plugin into a highly flexible tool for multi-dimensional data storytelling:

🚀 What is new in Version 0.0.3

This update focuses on fine-tuning the visual output, adding publication-ready details, and improving the user interface:

✨ New Features & Improvements:

🚀 What is new in Version 0.0.2


⚙️ Prerequisites

You must have RKWard installed along with the following R packages:

install.packages(c("ggplot2", "gganimate", "gifski", "transformr", "srvyr", "dplyr", "ggimage"))

🚀 Installation

You can install this plugin directly from GitHub using devtools:

# Install the plugin
# remotes::install_github("AlfCano/rk.gganimate")
install.packages("rk.gganimate", repos = c('https://alfcano.r-universe.dev', 'https://cloud.r-project.org'))

Once installed, open RKWard, navigate to Settings -> Configure RKWard -> Plugins, and activate rk.gganimate.


🛠️ Usage Workflow

This plugin adds a two-step toolkit under Survey -> Graphs -> Animations.

1. Data Prep for Animation (srvyr)

This tool crunches heavy survey data (millions of rows) into a lightweight table (one row per group per year) required for Gapminder-style animations.

  1. Source Data & Filters: Select your survey.design object.
  2. Grouping Dimensions: Select the Time variable (e.g., year) and one or more Grouping variables (e.g., State and Sector).
  3. Metrics: Select your continuous variable (to calculate the mean for the Y-Axis) and your categorical variable + target level (to calculate the % for the X-Axis).
  4. Click Submit. A summarized table (tabla_animacion) will be saved to your workspace.

2. Animated Bubble Chart

  1. Variables: Select tabla_animacion. Map your calculated X, Y, Size, and Color variables. Use the new Optional Filter box to dynamically subset your animation (e.g., Sector == 'Manufacturing').
  2. Labels & Theme: Set titles, tweak the color palette, and use the Storytelling frame to track specific bubbles (e.g., type Puebla, Jalisco to only display names for those specific bubbles while they move).
  3. Render & Export: Set your FPS and duration. Click Submit. The GIF will be rendered and embedded directly into your RKWard HTML output window!

3. Animated Line Chart

Shows growth over time using transition_reveal().

4. Bar Chart Race

The viral sliding bar ranking chart.


🧪 The Testing Workflow

To test the generated plugin and see the Storytelling tracking in action, paste this into the RKWard console to create a mock summarized dataset:

# Create a Mock Summarized Dataset (Gapminder Style)
set.seed(123)
mock_anim_data <- expand.grid(Year = 2010:2020, State = c("Puebla", "Jalisco", "Nuevo Leon", "CDMX", "Oaxaca"))
mock_anim_data$Income <- runif(nrow(mock_anim_data), 10000, 30000) + (mock_anim_data$Year - 2010) * 1000
mock_anim_data$Poverty_Pct <- runif(nrow(mock_anim_data), 20, 60) - (mock_anim_data$Year - 2010) * 1.5
mock_anim_data$Population <- runif(nrow(mock_anim_data), 1e6, 5e6)

Step-by-step Test:

  1. Open Survey > Graphs > Animations > 2. Animated Bubble Chart
    • Data Frame: Select mock_anim_data
    • X Axis: Select Poverty_Pct
    • Y Axis: Select Income
    • Time / Frame Variable: Select Year
    • Bubble Size: Select Population
    • Color / Group Category: Select State
  2. Go to the Labels & Theme Tab:
    • Main Title: Type Poverty vs Income (2010-2020)
    • Plot Theme: Minimal
    • Storytelling: Check the "Highlight specific bubbles" box.
    • Exact name(s) to track: Type Puebla, Nuevo Leon
  3. Go to the Render & Export Tab:
    • Frames per second: 10
    • Duration: 8 seconds
    • Save GIF as: Choose a folder on your computer (e.g., your Desktop) and name it test_animation.gif.
  4. Click Submit!
    • Note: Rendering a GIF takes a few seconds. Wait until RKWard says "Animation successfully saved".

Result: Check your Desktop. You will have a fluid 8-second animation where all bubbles move, but only "Puebla" and "Nuevo Leon" have a bold, floating label tracking their exact movement across the screen!


🌍 Internationalization (i18n)

The graphical interface automatically adapts to your RKWard language settings. Currently supported languages:


📝 License and Author

Author: Alfonso Cano (@AlfCano) Email: alfonso.cano@correo.buap.mx

This project is licensed under the GPL (>= 3) License.