Learn R Programming

chronicle (version 0.3)

make_boxplot: Create a box plot from a data frame through ggplotly

Description

Create a box plot from a data frame through ggplotly

Usage

make_boxplot(
  dt,
  value,
  groups = NULL,
  split_groups_by = NULL,
  jitter = FALSE,
  ggtheme = "minimal",
  x_axis_label = NULL,
  y_axis_label = NULL,
  plot_palette = NULL,
  plot_palette_generator = "plasma",
  static = FALSE
)

Arguments

dt

data.frame containing the data to plot.

value

Name of the column to use as values on the y axis of the plot.

groups

Name of the column containing the different groups.

split_groups_by

Second column to split each group by (eg, create inidivudal boxplots within the 'groups'.)

jitter

Whether to add the actual values of each observation over the box plots. Only done when dt has 10,000 rows or less.

ggtheme

ggplot2 theme function to apply. Default is ggplot2::theme_minimal.

x_axis_label

Label for the x axis.

y_axis_label

Label for the y axis.

plot_palette

Character vector of hex codes specifying the colors to use on the plot.

plot_palette_generator

Palette from the viridis package used in case plot_palette is unspecified or insufficient for the number of colors required.

static

If TRUE (or if the dataset is over 10,000 rows), the output will be static ggplot chart instead of an interactive ggplotly chart. Default is FALSE.

Value

A plotly-ized version of a ggplot box plot.

Examples

Run this code
# NOT RUN {
make_boxplot(dt = ggplot2::mpg, value = 'hwy', groups = 'drv', jitter = TRUE)

# }

Run the code above in your browser using DataLab