box_plot: Construct box plots.

View source: R/plot_functions.R

box_plotR Documentation

Construct box plots.

Description

box_plot is a wrap function that calls gf_boxplot to construct more aesthetic box plots.

Usage

box_plot(
  object = NULL,
  formula = NULL,
  data = NULL,
  fill = "indianred3",
  alpha = 0.7,
  outlier.shape = 20,
  outlier.size = 1,
  ...
)

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 where y is a numerical variable and x is a factor.

data

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

fill

Colour used for the box passed to gf_boxplot.

alpha

Opacity (0 = invisible, 1 = opaque).

outlier.shape

Shape (pch) used as symbol for the outliers.

outlier.size

Size of the outlier symbol.

...

Further arguments passed to gf_boxplot.

Examples

data(kfm, package = "ISwR")
require(sjlabelled, quietly = TRUE)
kfm <- kfm %>%
  var_labels(
    dl.milk = "Breast-milk intake (dl/day)",
    sex = "Sex",
    weight = "Child weight (kg)",
    ml.suppl = "Milk substitute (ml/day)",
    mat.weight = "Maternal weight (kg)",
    mat.height = "Maternal height (cm)"
  )

kfm %>%
  box_plot(dl.milk ~ sex, fill = "thistle", alpha = 0.8)

t.test(dl.milk ~ sex, data = kfm)

kfm %>%
  box_plot(dl.milk ~ sex, fill = "thistle", alpha = 0.8) %>%
  gf_star(1, 10.9, 2, 11, 11.4, legend = "p = 0.035", size = 2.5)

pubh documentation built on Nov. 14, 2023, 1:08 a.m.