exploding_boxplot: Interactive Exploding Boxplots

Description Usage Arguments Examples

Description

Create interactive d3.js exploding boxplots using d3_exploding_boxplot

Usage

1
2
3
exploding_boxplot(data, y = NULL, group = NULL, color = NULL,
  label = NULL, iqr = NULL, margin = NULL, xlab = NULL, ylab = NULL,
  width = NULL, height = NULL, elementId = NULL)

Arguments

data

data.frame to plot

y

string representing the column name for aes y

group

string representing the column name for aes group

color

string representing the column name for aes color

label

string representing the column name for aes label

margin

list in list(bottom = , left = , top = , right = ) format

xlab

string for the label of the x axis. Note, currently not working.

ylab

string for the label of the y axis.

width, height

any valid CSS size unit for the height and width of the htmlwidget

elementId

likely NULL unless you would like to manually specify a CSS selector id to the htmlwidget container

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
61
62
63
64
65
66
67
68
69
70
# devtools::install_github("timelyportfolio/explodingboxplotR")

library(explodingboxplotR)

# use this to replicate
#   from ?boxplot
#boxplot(count ~ spray, data = InsectSprays, col = "lightgray")

exploding_boxplot(
  data.frame(
    rowname = rownames(InsectSprays),
    InsectSprays,
    stringsAsFactors = FALSE
  ),
  y = "count",
  group = "spray",
  color = "spray",
  label = "rowname"
)

# demonstrate all of the options
#  xlab does not work
#  filed issue on source repo
exploding_boxplot(
  data.frame(
    rowname = rownames(InsectSprays),
    InsectSprays,
    stringsAsFactors = FALSE
  ),
  y = "count",
  group = "spray",
  color = "spray",
  label = "rowname",
  iqr = 2,
  margin = list(bottom = 50, left = 30, top = 20, right = 20),
  xlab = "Spray Type",
  ylab = "Count Provided"
)


# use new htmlwidgets on render to customize tooltip
htmlwidgets::onRender(
  exploding_boxplot(
    data.frame(
      rowname = rownames(InsectSprays),
      InsectSprays,
      stringsAsFactors = FALSE
    ),
    y = "count",
    group = "spray",
    color = "spray",
    label = "rowname"
  ),
  "
function(){
  this.chart.tip.html(function(d){
    return [
      '<span style = \\'font-size:150%\\'>',
      d.spray,
      ' |  ',
      '</span>',
      ' count of',
      d.count,
      ' from rowname ',
      d.rowname
    ].join('\\n')
  })
}
  "
)

timelyportfolio/explodingboxplotR documentation built on May 31, 2019, 1:49 p.m.