data(energy, package = "ISwR")
require(sjlabelled, quietly = TRUE)
energy <- energy |>
  var_labels(
    expend = "Energy expenditure (MJ/day)",
    stature = "Stature"
  )
energy |>
  strip_error(expend ~ stature, col = "red")
t.test(expend ~ stature, data = energy)
## Adding an horizontal line to show significant difference:
energy |>
  strip_error(expend ~ stature, col = "red") |>
  gf_star(1, 13, 2, 13.2, 13.4, "**")
data(birthwt, package = "MASS")
require(dplyr, quietly = TRUE)
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")
birthwt |>
  strip_error(bwt ~ smoke, col = ~Race)
birthwt |>
  strip_error(bwt ~ smoke, pch = ~Race, col = ~Race)
birthwt |>
  strip_error(bwt ~ smoke | Race)
Run the code above in your browser using DataLab