streamgraph: Create a new streamgraph

Description Usage Arguments Value Examples

View source: R/streamgraph.R

Description

streamgraph() initializes the streamgraph html widget and takes a data frame in "long" format with columns for the category (by default, it looks for key) and its associated date and value. You can supply the names for those columns if they aren't named as such in your data.

By default, interactivity is on, but you can disable that by setting the interactive parameter to FALSE.

Usage

1
2
3
4
5
streamgraph(data, key, value, date, width = NULL, height = NULL,
  offset = "silhouette", interpolate = "cardinal",
  interactive = TRUE, scale = "date", top = 20, right = 40,
  bottom = 30, left = 50, sort = TRUE, complete = TRUE,
  order = c("compat", "asis", "inside-out", "reverse"))

Arguments

data

data frame

key

bare or quoted name of the category column (defaults to key)

value

bare or quoted name of the value column (defaults to value)

date

bare or quoted name of the date column (defaults to date)

width

Width in pixels (optional, defaults to automatic sizing)

height

Height in pixels (optional, defaults to automatic sizing)

offset

see d3's offset layout for more details. The default is probably fine for most uses but can be one of silhouette (default), wiggle, expand or zero

interpolate

see d3's area interpolation for more details. The default is probably fine fore most uses, but can be one of cardinal (default), linear, step, step-before, step-after, basis, basis-open, cardinal-open, monotone

interactive

set to FALSE if you do not want an interactive streamgraph

scale

axis scale (date [default] or continuous)

top

top margin (default should be fine, this allows for fine-tuning plot space)

right

right margin (default should be fine, this allows for fine-tuning plot space)

bottom

bottom margin (default should be fine, this allows for fine-tuning plot space)

left

left margin (default should be fine, this allows for fine-tuning plot space)

sort

experimental

complete

experimental

order

streamgraph ribbon order. "'compat'" to match the orignial package behavior, "'asis'" to use the input order, "'inside-out'" to sort by index of maximum value, then use balanced weighting, or "'reverse'" to reverse the input layer order.

Value

streamgraph object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
library(dplyr)
library(streamgraph)
ggplot2movies::movies %>%
select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
  tidyr::gather(genre, value, -year) %>%
  group_by(year, genre) %>%
  tally(wt=value) %>%
  ungroup %>%
  mutate(year=as.Date(sprintf("%d-01-01", year))) -> dat

streamgraph(dat, "genre", "n", "year")

## End(Not run)

hrbrmstr/streamgraph documentation built on May 17, 2019, 5:14 p.m.