pubh (version 1.1.16)

bar_error: Bar charts with error bars.

Description

bar_error constructs bar charts in with error bars showing 95 confidence intervals around mean values. High of bars represent mean values.

Usage

bar_error(
  object = NULL,
  formula = NULL,
  data = NULL,
  fill = "indianred3",
  col = "black",
  alpha = 0.7,
  ...
)

Arguments

object

When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument. See details and examples.

formula

A formula with shape: y ~ x or y ~ x|z where y is a numerical variable and both x and z are factors.

data

A data frame where the variables in the formula can be found.

fill

Colour used to fill the bars.

col

Colour used for the borders of the bars.

alpha

Opacity of the colour fill (0 = invisible, 1 = opaque).

...

Additional information passed to gf_summary.

Examples

Run this code
# NOT RUN {
require(dplyr)
require(sjlabelled)
data(birthwt, package = "MASS")
birthwt <- birthwt %>%
  mutate(
    smoke = factor(smoke, labels = c("Non-smoker", "Smoker")),
    Race = factor(race > 1, labels = c("White", "Non-white"))
  ) %>%
  var_labels(
    bwt = 'Birth weight (g)',
    smoke = 'Smoking status'
 )

birthwt %>%
  bar_error(bwt ~ smoke, fill = 'plum3') %>%
  axis_labs()

birthwt %>%
  bar_error(bwt ~ smoke|Race, fill = 'plum3') %>%
  axis_labs()

birthwt %>%
  bar_error(bwt ~ smoke, fill = ~ Race) %>%
  axis_labs()

# }

Run the code above in your browser using DataCamp Workspace