Learn R Programming

pubh (version 3.0.0)

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(data, x, y, alpha = 0.7)

Arguments

data

A data frame.

x

A variable in the data frame.

y

A variable in the data frame

alpha

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

Examples

Run this code
require(dplyr, quietly = TRUE)
require(sjlabelled, quietly = TRUE)
data(birthwt, package = "MASS")

birthwt <- birthwt |>
  mutate(
    smoke = factor(smoke, labels = c("Non-smoker", "Smoker"))
  ) |>
  var_labels(
    bwt = "Birth weight (g)",
    smoke = "Smoking status"
  )

birthwt |>
  bar_error(x = smoke, y = bwt)

Run the code above in your browser using DataLab