mjs_add_confidence_band: Add a confidence band to line plot

Description Usage Arguments Examples

Description

If you have lower & upper points associated with your line in a data frame, you can specify their accessors (defaults to "l" & "u") here which will result in a shaded confidence band being plotted with the line.

Usage

1
mjs_add_confidence_band(mjs, lower_accessor = "l", upper_accessor = "u")

Arguments

mjs

metricsgraphics plot object

lower_accessor

bare or quoted name of column to use for the lower bound of the confidence band

upper_accessor

bare or quoted name of column to use for the upper boudn of the confidence band

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
require(binom)
require(dplyr)

set.seed(1492)
binom.confint(x=sample(2:30, 100, replace=TRUE), n = 100, tol = 1e-8,
              methods="bayes") %>%
  mutate(x=1:100) -> bdat

bdat %>%
  mjs_plot(x=x, y=mean, width=600, height=240) %>%
  mjs_axis_x(show_secondary_x_label=FALSE,
             extended_ticks=TRUE) %>%
  mjs_line() %>%
  mjs_add_confidence_band(lower_accessor="lower",
                          upper_accessor="upper")

metricsgraphics documentation built on May 1, 2019, 8:07 p.m.