Learn R Programming

onewaytests (version 2.5)

gplot: Box-and-Whisker Plots and Error Bars

Description

gplot produce box-and-whisker plots and error bars of the given grouped values.

Usage

gplot(formula, data, type = c("boxplot", "errorbar"), violin = TRUE, xlab = NULL, 
  ylab = NULL, title = NULL, width = NULL, option = c("se", "sd"), na.rm = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in the formula formula

type

a character string to select one of the plots. "boxplot": box-and-whisker plot, "errorbar": error bar.

violin

a logical adding violin plot on box-and-whisker plot.

xlab

a label for the x axis, defaults to a description of x.

ylab

a label for the y axis, defaults to a description of y.

title

a main title for the plot.

width

a numeric giving the width of the boxes for box-and-whisker plots (defaults to 0.3) and the width of the little lines at the tops and bottoms of the error bars (defaults to 0.15).

option

a character string to select one of the options to draw error bars with standard error or standard deviation. "se": standard error, "sd": standard deviation. Defaults to "se".

na.rm

a logical indicating whether NA values should be stripped before the computation proceeds.

Details

The upper whisker of box-and-whisker plots extends from the hinge to the highest value that is within 1.5 * IQR of the hinge, where IQR is the inter-quartile range. The lower whisker extends from the hinge to the lowest value within 1.5 * IQR of the hinge. Data out of the ends of the whiskers are outliers and plotted as points.

See Also

geom_boxplot geom_violin

Examples

Run this code
# NOT RUN {
library(onewaytests)

gplot(Sepal.Length ~ Species, data = iris, type = "boxplot")
gplot(Sepal.Length ~ Species, data = iris, type = "boxplot", violin = FALSE)
gplot(Sepal.Length ~ Species, data = iris, type = "errorbar", option = "se")
gplot(Sepal.Length ~ Species, data = iris, type = "errorbar", option = "sd")

# }

Run the code above in your browser using DataLab