Learn R Programming

metricsgraphics (version 0.9.0)

mjs_add_confidence_band: Add a confidence band to line plot

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

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

Run this code
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")

Run the code above in your browser using DataLab