box_plot: Construct box plots.

Description Usage Arguments Examples

View source: R/plot_functions.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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) %>%
  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)

pubh documentation built on Feb. 17, 2021, 1:08 a.m.