Description Usage Arguments Details Examples
This function can create a variety of interactive d3 visualizations from tables and data.frames.
1 2 3 4 5 6 7 | hiervis(data, vis = NULL, width = NULL, height = NULL,
elementId = NULL, nameField = "name", valueField = "value",
pathSep = NULL, parentField = NULL, stat = "count",
vis.opts = list(transitionDuration = 350, showNumbers = TRUE,
numberFormat = ",d", treeColors = TRUE, treemapHier = TRUE,
sunburstLabelsRadiate = FALSE, circleNumberFormat = ".2s", linkColorChild
= FALSE, sankeyMinHeight = NULL))
|
data |
tabular data or data.frame |
vis |
One of "sankey", "sunburst", "partition", "treemap". |
width |
width of widget |
height |
height of widget |
elementId |
elementId |
nameField |
field in data that has the name or ID |
valueField |
field in data that has quantitative values |
pathSep |
path separator in name field, e.g. "/" |
parentField |
field in data that has the parent name or ID |
stat |
a statistic to calculate the value, e.g. "count" |
vis.opts |
additional parameters given to the javascript hiervis function |
- tabular data can be used directly without extra arguments - For data.frames or matrices with a path (e.g. "A/B/C"), specify nameField, pathSep and valueField - For data.frames or matrices with parent and child fields, specify nameField and parentField
1 2 3 4 5 6 7 8 9 10 11 12 13 | data(Titanic)
## Tabular data does not need any extra arguments
hiervis(Titanic, "sankey")
hiervis(HairEyeColor, "vertical sankey")
## For data.frames with a path (e.g. A/B/C), supply nameField, pathSep and valueField
hiervis(d3_modules, "sunburst", nameField = "path", pathSep = "/", valueField = "size")
## For data.frames with parent and child field, supply nameField and parentField
data <- data.frame(name = c("Root Node", "Node A", "Node B", "Leaf Node A.1", "Leaf Node A.2"),
parent = c(NA, "Root Node", "Root Node", "Node A", "Node A"))
hiervis(data, "sankey", nameField = "name", parentField = "parent", stat = "count")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.