ggBoxplot: Box plot using ggplot

Description Usage Arguments Details Value Author(s) See Also Examples

Description

This function provides a simple interface to create a ggplot box plot, organising different boxplots by levels of a factor is desired, and showing row numbers of outliers.

Usage

1
2
3
4
ggBoxplot(dat, y = NULL, x = NULL,
          labelOutliers = TRUE,
          outlierColor = "red",
          theme = theme_bw(), ...)

Arguments

dat

Either a vector of values (to display in the box plot) or a dataframe containing variables to display in the box plot.

y

If dat is a dataframe, this is the name of the variable to make the box plot of.

x

If dat is a dataframe, this is the name of the variable (normally a factor) to place on the X axis. Separate box plots will be generate for each level of this variable.

labelOutliers

Whether or not to label outliers.

outlierColor

If labeling outliers, this is the color to use.

theme

The theme to use for the box plot.

...

Any additional arguments will be passed to geom_boxplot.

Details

This function is based on JasonAizkalns' answer to a question on Stack Exchange (Cross Validated; see http://stackoverflow.com/questions/33524669/labeling-outliers-of-boxplots-in-r).

Value

A ggplot plot is returned.

Author(s)

Jason Aizkalns; implemented in this package (and tweaked a bit) by Gjalt-Jorn Peters.

Maintainer: Gjalt-Jorn Peters <gjalt-jorn@userfriendlyscience.com>

See Also

geom_boxplot

Examples

1
2
3
4
5
### A box plot for miles per gallon in the mtcars dataset:
ggBoxplot(mtcars$mpg);

### And separate for each level of 'cyl' (number of cylinder):
ggBoxplot(mtcars, y='mpg', x='cyl');

Matherion/userfriendlyscience documentation built on May 7, 2019, 3:41 p.m.