pubh (version 1.1.16)

box_plot: 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

Run this code
# NOT RUN {
data(kfm, package = "ISwR")
require(sjlabelled)
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) %>%
  axis_labs()

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

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

Run the code above in your browser using DataCamp Workspace