choroplethr_animate: Animate a list of choropleths

View source: R/choroplethr_animate.R

choroplethr_animateR Documentation

Animate a list of choropleths

Description

Given a list of choropleths, represented as ggplot2 objects

  1. Save the individual images to the working directory with the naming convention "choropleth_1.png", "choropleth_2.png", etc.

  2. Write a file called "animated_choropleth.html" which contains a viewer which animates them.

Usage

choroplethr_animate(choropleths)

Arguments

choropleths

A list of choropleths represented as ggplot2 objects.

Value

Nothing. However, a variable number of files are written to the current working directory.

Author(s)

Ari Lamstein (R code) and Brian Johnson (JavaScript, HTML and CSS code)

Examples

## Not run: 
data(df_president_ts)
?df_president_ts # time series of all US presidential elections 1789-2012

# create a list of choropleths of presidential election results for each year
choropleths = list()
for (i in 2:(ncol(df_president_ts))) {
  df           = df_president_ts[, c(1, i)]
  colnames(df) = c("region", "value")
  title        = paste0("Presidential Election Results: ", colnames(df_president_ts)[i])
  choropleths[[i-1]] = state_choropleth(df, title=title)
}

# set working directory and animate
setwd("~/Desktop")
choroplethr_animate(choropleths)

## End(Not run)

choroplethr documentation built on May 29, 2024, 1:20 a.m.