gvisSankey: Google Sankey Chart with R \Sexpr{googleChartName <-...

View source: R/gvisSankey.R

gvisSankeyR Documentation

Google Sankey Chart with R \Sexpr{googleChartName <- "sankey"} \Sexpr{gvisChartName <- "gvisSankey"}

Description

A sankey diagram is a visualization used to depict a flow from one set of values to another. The things being connected are called nodes and the connections are called links. They're named after Captain Sankey, who created a diagram of steam engine efficiency that used arrows having widths proportional to heat loss.

Usage

gvisSankey(data, from = "", to = "", weight = "", options = list(), chartid)

Arguments

data

data.frame that contains the data to be visualised

from

a string that refers to the column name in data for the source nodes to be used

to

a string that refers to the column name in data for the destination nodes to be used

weight

name of the column with the numerical weight of the connections

options

list of configuration options. The options are documented in detail by Google online:

\Sexpr[results=rd]{gsub("CHARTNAME", googleChartName, readLines(file.path(".", "inst", "mansections", "GoogleChartToolsURLConfigOptions.txt")))} \Sexpr[results=rd]{paste(readLines(file.path(".", "inst", "mansections", "gvisOptions.txt")))}
chartid

character. If missing (default) a random chart id will be generated based on chart type and tempfile

Value

\Sexpr[results=rd]{paste(gvisChartName)}

returns list of class \Sexpr[results=rd]{paste(readLines(file.path(".", "inst", "mansections", "gvisOutputStructure.txt")))}

Warning

The sankey chart may be undergoing substantial revisions in future Google Charts releases.

Author(s)

Markus Gesmann markus.gesmann@gmail.com

References

Google Chart Tools API: \Sexpr[results=rd]{gsub("CHARTNAME", googleChartName, readLines(file.path(".", "inst", "mansections", "GoogleChartToolsURL.txt")))}

Examples

dat <- data.frame(From=c(rep("A",3), rep("B", 3)), 
                  To=c(rep(c("X", "Y", "Z"),2)), 
                  Weight=c(5,7,6,2,9,4))

sk1 <- gvisSankey(dat, from="From", to="To", weight="Weight")
plot(sk1)

sk2 <- gvisSankey(dat, from="From", to="To", weight="Weight",
                options=list(sankey="{link: {color: { fill: '#d799ae' } },
                                     node: { color: { fill: '#a61d4c' },
                                     label: { color: '#871b47' } }}"))
plot(sk2)


mages/googleVis documentation built on March 5, 2023, 6:16 a.m.