mk_boxplot: Create a function for making publishable ggplot2 boxplots.

View source: R/mk_boxplot.R

mk_boxplotR Documentation

Create a function for making publishable ggplot2 boxplots.

Description

mk_boxplot takes a data frame as input and returns a function for making boxplots with any categorical variable from the data frame on the x-axis and any continuous variable on the y-axis. The output function can also produce dodged boxplots when supplied a second categorical variable, a fillby variable.

Usage

mk_boxplot(df)

Arguments

df

A data frame.

Value

function(xvar = "1", yvar, fillby = "1", notched = FALSE, legend_title = fillby, legend_pos = "right", label_size = 3, font_size = 14)

  • xvar. String, name of a categorical variable for x-axis. Default = "1", just draw a boxplot of yvar by itself.

  • yvar. String, name of a continuous variable for y-axis.

  • fillby. String, name of a different categorical variable for breaking down the y values of each box. Default = "1", meaning no such variable is supplied.

  • notched. Logical, draw notched boxplots when TRUE; otherwise, draw regular boxplots. Default = FALSE.

  • legend_title. String, legend title. Default is the name of the fillby variable.

  • legend_pos. String, legend position. Default = "right".

  • label_size. Integer, size of bar label text. Default = 3.

  • font_size. Overall font size. Default = 14. The font size of the axes and legend text is a fraction of this value.

Examples

inst/examples/ex-mk_boxplot.R

gmlang/ezplot documentation built on Sept. 18, 2022, 6:33 a.m.