parcoords provides an interactive view (parcoords-es) of multivariate data sets that fully integrates with Shiny and crosstalk.

Quick Example

The default view provides limited interactivity. Through various arguments to parcoords, we can provide a more immersive customized experience.

library(parcoords)

parcoords(mtcars, height = 450)

Options

Brushing

We have multiple brush types available through the brushMode argument, which allow a user the ability to filter/select the data.

In addition to the brush mode, we have some other supporting arguments for additional customization, such as brushPredicate and alphaOnBrushed. Contrast with the above chart to see the differences in behavior.

Color

Color can be a single color as rgb or hex value.

We can also control color with a function by providing a list( colorScale = , colorBy = , colorScheme =, colorInterpolator = , colorDomain =) where colorScale is the name of the d3-scale such as scaleOrdinal or scaleSequential and colorBy is the column name from the data to determine color. If appplying color to a discrete or ordinal variable then please also supply colorScheme, such as schemCategory10. If applying color to a continuous variable then please also supply colorInterpolator as the name of the d3 interpolator, such as interpolateViridis. If using a d3 color scale, then make sure to use the argument withD3 = TRUE. Hopefully, the examples below help clarify the concept.

For coloring with a continuous variable, the list will be slightly different with colorScale = 'scaleSequential' as the most likely option. interpolateViridis is the default interpolator, and we use interpolateMagma below.

Bundling

Bundling can help with bigger data sets. For the sake of size, we will continue to use with mtcars below. To see the effect, you might like to try with survival::colon or ggplot2::diamonds.

Queue and Rate

With larger (> 1000 rows) datasets, interactivity can slow dramatically unless you use queue = TRUE with rate, which will require a little experimentation to get right. As above, we’ll use with mtcars, but really you should only need these options with much larger datasets.

Tiling Mode

I have included mode = 'tiled' to experiment with the technique proposed in

Tile-based parallel coordinates and its application in financial visualization

Jamal Alsakran, Ye Zhao, and Xinlei Zhao

I would love feedback on this for improvement or suggestions. While the technique is designed for larger datasets, this code has not been optimized and does not use a cache, so it actually slows down as the data grows larger. This option does not make sense with mtcars but for example purposes we will continue to use this smaller dataset.

Methods

The package provides some helper methods for use in standalone or Shiny contexts. For instance, we can use the snapshot to provide a png export of the current state of the parallel coordinates chart.

Snapshot

The prior version of parallel coordinates had some very basic support for capturing the chart as a static image. However, the functionality was not complete, and the implementation was buggy. Now, taking snapshots of the parallel coordinates chart is available through JavaScript and R. The resulting image will also record the current state of brushes.

Proxy Methods for Shiny Use

Similar to leaflet and plotly, parcoords offers proxy methods to interact with parallel coordinates in Shiny without a full re-render. Currently, the following functions (namespaced by pc*) are available.

  • pcFilter
  • pcCenter
  • pcSnapshot
  • pcHide
  • pcUnhide
  • pcSnapshot

See ?parcoords-shiny for some examples.