NEW! Export HTML5 animations with ndtv-d3

The ndtv package now includes a command render.d3movie which will export an HTML5 SVG animation of a network movie that can be be viewed in a modern web browser. This does not require installing additional components on your system. Examples at

Installing ndtv and its external dependencies The ndtv: Network Dynamic Temporal Visualizations package renders dynamic network data from networkDynamic objects as animated movies or other representations of relational structure and node attributes that change over time. It relies on many other packages to do much of the heavy lifting, especially animation and networkDynamic. For some features, it also requires external libraries (FFmpeg) to save movies out of the R environment, and Java to be able to apply some of the better layout algorithms.

These instructions are copied from the ndtv tutorial and most of the content can also be found in the R help files for the various functions indicated. These instructions assume you already have a R installed

Getting started with ndtv

There a several ways to try out the ndtv features

  • The ndtv package vignette (can be displayed with browseVignette(package='ndtv)).
  • There is a longer and more detailed ndtv tutorial.
  • the ndtv-d3 HTML5 animation component has its own tutorial
  • The help file ?render.animation is a good place to get started in the technical documentation. A PDF version of the complete documentation is on CRAN.
  • Or jump right in with:
    # load an example dataset
    # render an animation in the R plot window
    # play back the animation in the R plot window
    # open the HTML5 version of the animation in a web browser

Installing the ndtv R package

R can automatically install the packages ndtv depends on when ndtv is installed. So open up your R console, and run the following command:

install.packages('ndtv',repos='', dependencies=TRUE)

If the installation worked, than the following command should load the package and print version information.

library(ndtv) # also loads animation and networkDynamic packages

Installing FFmpeg for saving animations

In order to save out animations as video files and use the better-quality layouts, we need to install some additional non-R software dependencies on the computer. FFmpeg is a cross-platform tool for converting and rendering video content in various formats. It is used as an external library by the animation package to save out the animation as a movie file on disk. (see ?saveVideo for more information.) The instructions for how to do this will be different on each platform. You can also access these instructions using ?install.ffmpeg.

Windows FFmpeg instructions

  • Download the recent 'static' build from
  • Downloads are compressed with 7zip, so you may need to first install a 7zip decompression program before you can unpack the installer.
  • Decompress the package and store contents on your computer (probably in Program Files)
  • Edit your system path variable to include the path to the directory containing mpeg.exe


Mac FFmpeg instructions


Linux / Unix FFmpeg instructions

  • FFmpeg or the alternate avconv is a standard package on many Linux systems. You can check if it is installed with a command like dpkg -s ffmpeg. If it is not installed, you should be able to install with your system's package manager. i.e. sudo apt-get install ffmpeg or search 'mpeg' in the Software Center on Ubuntu.

After you have installed FFmpeg on your system, you can verify that R knows where to nd it by typing


in the R terminal, this should print out the path. You many need to first restart R after the install.

Installing Java and MDSJ setup

To use the MDSJ layout algorithm, you must have Java installed. Java should be already installed by default on most Mac and Linux systems. If it is not installed, you can download it from On Windows, you may need to edit your `Path' environment variable to make Java executable from the command-line.

When java is installed correctly the following command should print out the version information:

system('java -version')

Due to CRAN's license restrictions, necessary components of the MDSJ layout (which we will use in a minute) are not distributed with ndtv. Instead, the first time the MDSJ layout is called after installing or updating the ndtv package, it is going to ask to download the library. Lets do that now on a pretend movie to get it out of the way:


This will give a prompt like

The MDSJ Java library does not appear to be installed.
The ndtv package can use MDSJ to provide a fast
accurate layout algorithm. It can be downloaded from
Do you want to download and install the MDSJ Java library? (y/N):

Responding y to the prompt should install the library and print the following message:

MDSJ is a free Java library for Multidimensional Scaling (MDS).
It is a free, non-graphical, self-contained, lightweight
implementation of basic MDS algorithms and intended to be used
both as a standalone application and as a building block in
Java based data analysis and visualization software.
CITATION: Algorithmics Group. MDSJ: Java Library for
Multidimensional Scaling (Version 0.2). Available at
University of Konstanz, 2009.
USE RESTRICTIONS: Creative Commons License 'by-nc-sa' 3.0.
Last modified 4 years ago Last modified on 11/09/15 21:51:52

Attachments (1)

Download all attachments as: .zip