parcoords: Interactive 'd3.js' Parallel Coordinates Chart

Description Usage Arguments Value Examples

Description

Create interactive parallel coordinates charts with this htmlwidget wrapper for d3.js parallel-coordinates.

Usage

1
2
3
4
5
6
7
8
parcoords(data = NULL, rownames = TRUE, color = NULL,
  brushMode = NULL, brushPredicate = "and", alphaOnBrushed = NULL,
  reorderable = FALSE, axisDots = NULL, margin = NULL,
  composite = NULL, alpha = NULL, queue = FALSE, mode = FALSE,
  rate = NULL, dimensions = NULL, bundleDimension = NULL,
  bundlingStrength = 0.5, smoothness = 0, tasks = NULL,
  autoresize = FALSE, withD3 = FALSE, width = NULL, height = NULL,
  elementId = NULL)

Arguments

data

data.frame with data to use in the chart

rownames

logical use rownames from the data.frame in the chart. Regardless of this parameter, we will append rownames to the data that we send to JavaScript. If rownames equals FALSE, then we will use parallel coordinates to hide it.

color

Color can be a single color as rgb or hex. For a color function, provide a list( colorScale = , colorBy = , colorScheme =, colorInterpolator = , colorDomain =) where colorScale is the name of the d3-scale such as scaleOrdinal or scaleSequential, colorBy with 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 with 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.

brushMode

string, either "1D-axes", "1D-axes-multi", or "2D-strums" giving the type of desired brush behavior for the chart.

brushPredicate

string, either "and" or "or" giving the logic forthe join with multiple brushes.

alphaOnBrushed

opacity from 0 to 1 when brushed (default to 0).

reorderable

logical enable reordering of axes

axisDots

logical mark the points where polylines meet an axis with dots

margin

list of sizes of margins in pixels. Currently brushMode = "2D-strums" requires left margin = 0, so this will change automatically and might result in unexpected behavior.

composite

foreground context's composite type

alpha

opacity from 0 to 1 of the polylines

queue

logical (default FALSE) to change rendering mode to queue for progressive rendering. Usually queue = T for very large datasets.

mode

string seequeue above; queue = T will set mode = "queue"

rate

integer rate at which render will queue

dimensions

list to customize axes dimensions

bundleDimension

character string for the column or variable on which to bundle

bundlingStrength

numeric value between 0 and 1 for the strength of the bundling. This value will not affect the parallel coordinates if bundleDimension is not set and will be ignored.

smoothness

numeric value between between 0 and 1 for stength of smoothing or curvature. This value will not affect the parallel coordinates if bundleDimension is not set and will be ignored.

tasks

a character string or JS or list of strings or JS representing a JavaScript function(s) to run after the parcoords has rendered. These provide an opportunity for advanced customization. Note, the function will use the JavaScript call mechanism, so within the function, this will be an object with this.el representing the containing element of the parcoords and this.parcoords representing the parcoords instance.

autoresize

logical (default FALSE) to auto resize the parcoords when the size of the container changes. This is useful in contexts such as rmarkdown slide presentations or flexdashboard. However, this will not be useful if you expect bigger data or a more typical html context.

withD3

logical to include d3 dependency from d3r. The 'parcoords' htmlwidget uses a standalone JavaScript build and will not include the entire d3 in the global/window namespace. To include d3.js in this way, use withD3=TRUE.

width

integer in pixels defining the width of the widget. Autosizing to 100 of the widget container will occur if width = NULL .

height

integer in pixels defining the height of the widget. Autosizing to 400px of the widget container will occur if height = NULL .

elementId

unique CSS selector id for the widget.

Value

An object of class htmlwidget that will intelligently print itself into HTML in a variety of contexts including the R console, within R Markdown documents, and within Shiny output bindings.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
if(interactive()) {
  # simple example using the mtcars dataset
  data( mtcars )
  parcoords( mtcars )

  # various ways to change color
  #   in these all lines are the specified color
  parcoords( mtcars, color = "green" )
  parcoords( mtcars, color = "#f0c" )
  #   in these we supply a function for our color
  parcoords(
    mtcars
    , color = list(
       colorBy = "cyl"
       , colorScale = "scaleOrdinal"
       , colorScheme = "schemeCategory10"
    )
    , withD3 = TRUE
  )

  if(require('ggplot2', quietly = TRUE)) {
  parcoords(
    diamonds
    ,rownames = FALSE
    ,brushMode = "1d-axes"
    ,reorderable = TRUE
    ,queue = TRUE
    ,color= list(
       colorBy="cut"
       , colorScale = "scaleOrdinal"
       , colorScheme = "schemeCategory10"
    )
    ,withD3 = TRUE
  )
  }
}
library(parcoords)

parcoords(
  mtcars,
  dimensions = list(
    cyl = list(
      title = "cylinder",
      tickValues = unique(mtcars$cyl)
    )
  )
)

parcoords(
  mtcars
  ,rownames = FALSE
  ,brushMode = "1d-multi"
  ,brushPredicate = "OR"
  ,dimensions = list(
    cyl = list(
      title = "cylinder",
      tickValues = unique(mtcars$cyl)
    )
  )
)

Example output



parcoords documentation built on May 24, 2019, 5:06 p.m.