pubh (version 1.1.16)

strip_error: Strip plots with error bars.

Description

strip_error constructs strip plots with error bars showing 95 confidence intervals around mean values.

Usage

strip_error(
  object = NULL,
  formula = NULL,
  data = NULL,
  pch = 20,
  size = 1,
  alpha = 0.7,
  col = "indianred3",
  ...
)

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.

pch

Point character passed to gf_point or gf_jitter.

size

Size of the symbol (pch) for representing data values.

alpha

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

col

A colour or formula used for mapping colour.

...

Additional information passed to gf_jitter or gf_point.

Examples

Run this code
# NOT RUN {
data(energy, package="ISwR")
require(sjlabelled)
energy = energy %>%
  var_labels(
    expend = 'Energy expenditure (MJ/day)',
    stature = 'Stature'
  )

energy %>%
  strip_error(expend ~ stature, col = 'red') %>%
  axis_labs()

t.test(expend ~ stature, data = energy)

## Adding an horizontal line to show significant difference:
energy %>%
  strip_error(expend ~ stature, col = 'red') %>%
  axis_labs() %>%
  gf_star(1, 13, 2, 13.2, 13.4, "**")

data(birthwt, package = "MASS")
require(dplyr)
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 %>%
  strip_error(bwt ~ smoke|Race, col = 'darksalmon') %>%
  axis_labs()

birthwt %>%
  strip_error(bwt ~ smoke, col = ~ Race) %>%
  gf_refine(ggsci::scale_color_jama()) %>%
  axis_labs()

birthwt %>%
  strip_error(bwt ~ smoke, pch = ~ Race, col = ~ Race) %>%
  gf_refine(ggsci::scale_color_jama()) %>%
  axis_labs()

birthwt %>%
  strip_error(bwt ~ smoke|Race) %>%
  axis_labs()
# }

Run the code above in your browser using DataLab