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.

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.

Examples

data(df_president_ts) ?df_president_ts # time series of all US presidential elections 1789-2012
#> Rendering development documentation for 'df_president_ts'
# 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) }
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, louisiana, minnesota, mississippi, montana, new mexico, north dakota, oklahoma, tennessee, california, west virginia, wisconsin, wyoming, alabama, alaska, florida, idaho, kansas, colorado, north carolina, washington, vermont, utah, iowa, kentucky, maine, michigan, missouri, nebraska, nevada, ohio, oregon, rhode island, south dakota, district of columbia, texas, hawaii, illinois, indiana
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, louisiana, minnesota, mississippi, montana, new mexico, north dakota, oklahoma, tennessee, california, west virginia, wisconsin, wyoming, alabama, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, maine, michigan, missouri, nebraska, nevada, ohio, oregon, south dakota, district of columbia, texas, hawaii, illinois, indiana
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, louisiana, minnesota, mississippi, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alabama, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, maine, michigan, missouri, nebraska, nevada, ohio, oregon, south dakota, district of columbia, texas, hawaii, illinois, indiana
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, louisiana, minnesota, mississippi, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alabama, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, maine, michigan, missouri, nebraska, nevada, ohio, oregon, south dakota, district of columbia, texas, hawaii, illinois, indiana
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, louisiana, minnesota, mississippi, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alabama, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, maine, michigan, missouri, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii, illinois, indiana
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, louisiana, minnesota, mississippi, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alabama, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, maine, michigan, missouri, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii, illinois, indiana
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, minnesota, mississippi, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alabama, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, maine, michigan, missouri, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii, illinois, indiana
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, minnesota, mississippi, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alabama, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, maine, michigan, missouri, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii, illinois
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, minnesota, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, michigan, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, minnesota, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, michigan, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, minnesota, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, michigan, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, minnesota, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, michigan, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, minnesota, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, minnesota, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, minnesota, montana, new mexico, north dakota, oklahoma, california, west virginia, wisconsin, wyoming, alaska, florida, idaho, kansas, colorado, washington, utah, iowa, nebraska, nevada, oregon, south dakota, district of columbia, texas, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, minnesota, montana, new mexico, north dakota, oklahoma, california, west virginia, wyoming, alaska, idaho, kansas, colorado, washington, utah, nebraska, nevada, oregon, south dakota, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, minnesota, montana, new mexico, north dakota, oklahoma, west virginia, wyoming, alaska, idaho, kansas, colorado, washington, utah, nebraska, nevada, oregon, south dakota, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, minnesota, montana, new mexico, north dakota, oklahoma, west virginia, wyoming, alaska, idaho, kansas, colorado, washington, utah, nebraska, nevada, oregon, south dakota, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, montana, new mexico, north dakota, oklahoma, west virginia, wyoming, alaska, idaho, kansas, colorado, washington, utah, nebraska, nevada, south dakota, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, arkansas, louisiana, mississippi, montana, new mexico, north dakota, oklahoma, tennessee, virginia, wyoming, alabama, alaska, florida, idaho, colorado, north carolina, south carolina, washington, utah, nebraska, south dakota, district of columbia, texas, georgia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, mississippi, montana, new mexico, north dakota, oklahoma, virginia, wyoming, alaska, idaho, colorado, washington, utah, south dakota, district of columbia, texas, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, montana, new mexico, north dakota, oklahoma, wyoming, alaska, idaho, colorado, washington, utah, south dakota, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, montana, new mexico, north dakota, oklahoma, wyoming, alaska, idaho, washington, utah, south dakota, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, montana, new mexico, north dakota, oklahoma, wyoming, alaska, idaho, washington, utah, south dakota, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, montana, new mexico, north dakota, oklahoma, wyoming, alaska, idaho, washington, utah, south dakota, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, montana, new mexico, north dakota, oklahoma, wyoming, alaska, idaho, washington, utah, south dakota, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, new mexico, oklahoma, alaska, utah, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, new mexico, oklahoma, alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, new mexico, oklahoma, alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, new mexico, oklahoma, alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: arizona, new mexico, alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: alaska, district of columbia, hawaii
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
#> Warning: Your data.frame contains the following regions which are not mappable: d.c.
#> Warning: Column `region` joining character vector and factor, coercing into character vector
#> Warning: The following regions were missing and are being set to NA: district of columbia
# set working directory and animate setwd("~/Desktop") choroplethr_animate(choropleths)
#> [1] "All files will be written to the current working directory: /Users/arilamstein/Desktop . To change this use setwd()" #> [1] "Now writing individual choropleth files there as 'choropleth_1.png', 'choropleth_2.png', etc."
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> Saving 7 x 7 in image
#> [1] "Now writing code to animate all images in 'animated_choropleth.html'. Please open that file with a browser."