Learn R Programming

⚠️There's a newer version (2017.01.04) of this package.Take me there.

animint - an R package for animated interactive web graphics

Animint makes it possible to design multi-layer, multi-plot, interactive, and possibly animated data visualizations using just a few lines of R code. Animint adds clickSelects and showSelected aesthetics to ggplot2, and renders using D3. For example, this multi-layer facetted interactive animation of WorldBank data was defined using only about 60 lines of R code.

Installation

if (!require(devtools)) install.packages("devtools")
devtools::install_github("tdhock/animint", upgrade_dependencies=FALSE)
library(animint)
example(animint)

NOTE: animint now works with standard ggplot2 >= 2.0 thanks to Faizan and Kevin! If you want to use the animint chunk_vars option then you will need to install hadley/ggplot2#1649 (it permits non-standard geom options).

Learning animint through examples

The best way to learn animint is through examples. A couple of good introductions are Carson Sievert's Interactive animations of PITCHf/x and Susan VanderPlas' animint tutorial. In addition, there is an examples web site, examples distributed with animint, as well as more complex 'big data' examples in the tdhock/animint-examples repo.

Frequently asked questions (FAQ)

Contribute to animint!

Write tests to increase code coverage

The easiest way to contribute to animint is by writing a new test that would increase the code coverage. First check the coveralls status page and find a part of the code which is not tested. Then fork animint and commit a new test that increases the coverage, and send us a Pull Request. It may be useful to read about our testing framework.

Learn about the design and theory of animint

Before adding features to animint, you should first read about its design. There are two main components, which have separate wiki pages that explain their details:

It would also be useful to read some theory in the academic paper describing Animint. It explains:

  • the purpose of animint: make it easy to design data visualizations

which can be both animated and interactive.

  • the clickSelects and showSelected keywords which permit

interactive linked plots.

  • the advantages and disadvantages of animint compared to other

interactive data viz libraries.

It may also be useful to read our short and long tables of related work.

TODO list of features to implement

We keep a TODO list at top of the NEWS file. Feel free to implement one and send us a PR. They are categorized as follows:

  • BUG: things which used to work but have stopped working. Tests should be added to prevent these. For example at one point in 2013, animint rendered the correct number of legend entries for the WorldBank viz, but in the beginning of 2014 animint rendered too many legend entries.
  • GGPLOT: things which ggplot2 supports but animint does not yet support. For example facets, coord_equal.
  • DSL: changes to the animint domain-specific language (DSL) which would allow interactive/animated features. These involve changes to how we define the ggplots, and how the compiler works. For example custom alpha/color/etc for selected geoms, using selected.alpha/selected.color/etc aesthetics.
  • EXAMPLE: examples to show off animint features, which should affect neither the compiler nor renderer.
  • RENDER: changes to the JavaScript rendering code which would result in better interactive plots, without having to change the definition of the ggplots. For example rendering a selection widget for every selection variable.
  • OUTPUT: different output formats for viewing/sharing an interactive animation.
  • OPTIMIZATION: things which are currently supported, but with an implementation that could be improved in terms of render/compile speed, disk usage, memory, etc. Typically these optimizations are not really noticed for small data sets, but make it easier to visualize large data sets. For example, can we gzip the TSV plot data files to reduce disk space and download times?

Copy Link

Version

Version

2016.07.12

License

GPL-3

Maintainer

Toby Dylan Hocking

Last Published

July 24th, 2019

Functions in animint (2016.07.12)

animintOutput

Shiny ui output function
FunctionalPruning

Functional Pruning Algorithm
climate

Climate data in central America from 1995 to 2000
breakpoints

The breakpointError of simulated signals
animint-package

Interactive animations
animint2gist

Convert a list of ggplots to an interactive animation and post files as a gist
animint2dir

Compile and render an animint in a local directory
ChromHMMiterations

ChromHMM iterations
change

Graphical model structure change
compare

Testing rank and compare SVM on simulated patterns
getLegendList

Function to get legend information from ggplot
getLegend

Function to get legend information for each scale
geom_widerect

ggplot2 geom with ymin and ymax aesthetics that covers the entire x range, useful for clickSelects background elements.
getCommonChunk

Save the common columns for each tsv to one chunk
is.rgb

Check if character is an RGB hexadecimal color value
intreg

Interval regression
gg2animint

animint2dir
knit_print.animint

Insert an interactive animation into an R markdown document using a customized print method.
geom_tallrect

ggplot2 geom with xmin and xmax aesthetics that covers the entire y range, useful for clickSelects background elements.
generation.loci

Evolution simulation
merge_recurse

Merge a list of data frames.
make_text

Convenvience function for a showSelected plot label.
pirates

Worldwide pirate attacks from 1978 to 2013
makeDocs

Make documentation web site.
parsePlot

Convert a ggplot to a list.
mixtureKNN

K-Nearest-Neighbors model of the mixture example data
make_tallrect

Make a clickSelects geom_tallrect that completely tiles the x range. This makes it easy to construct tallrects for the common case of selecting a particular x value.
make_bar

Convenience function for an interactive bar that might otherwise be created using stat_summary(geom="bar").
malaria

Malaria parasite genome variants
PeakConsistency

Consistency of segmentation models in simulated Poisson peaks
selector.aes

Parse selectors from aes names.
split.x

Split data.frame into recursive list of data.frame.
renderAnimint

Create an animint output element
TestROC

Test ROC curves
prior

Class prior change
saveChunks

Split data set into chunks and save them to separate files.
scale_size_animint

Scale point sizes using circle area, but specifying the radius in pixels.
tests_exit

Kill child process(es) that may have been initiated in animint testing
run_servr

Spawn a child R session that runs a 'blocking' command
saveLayer

Save a layer to disk, save and return meta-data.
transform_shape

Function to transform R shapes into d3 shapes...
theme_animint

Theme without checks. This allows us to write theme_animint(width=500), instead of theme(animint.width=500) which gives an error in ggplot2 because users should be informed if they mis-type standard theme element names. https://github.com/hadley/ggplot2/issues/938
UStornadoes

Tornadoes in the United States from 1950 to 2012
toRGB

Convert R colors to RGB hexadecimal color values
tests_run

Run animint tests
tests_init

Initiate external processes necessary for running tests.
VariantModels

Error rates of supervised learning methods for variant calling
varied.chunk

Extract subset for each data.frame in a list of data.frame
WorldBank

Demographics by country from 1960 to 2012
vervet

Vervet monkey intestinal microbiome
worldPop

World population by subcontinent