Learn R Programming

DataExplorer (version 0.6.0)

plot_boxplot: Create boxplot for continuous features

Description

This function creates boxplot for each continuous feature based on a selected feature.

Usage

plot_boxplot(data, by, title = NULL, ggtheme = theme_gray(),
  theme_config = list(), ...)

Arguments

data

input data

by

feature name to be broken down by. If selecting a continuous feature, boxplot will be grouped by 5 equal ranges, otherwise, all existing categories for a discrete feature.

title

plot title

ggtheme

complete ggplot2 themes. The default is theme_gray.

theme_config

a list of configurations to be passed to theme.

other arguments to be passed to geom_boxplot.

Details

To change default font family and size, you may pass base_size and base_family to ggtheme options, e.g., ggtheme = theme_gray(base_size = 15, base_family = "serif")

theme_config argument expects all inputs to be wrapped in a list object, e.g., to change the text color: theme_config = list("text" = element_text(color = "blue"))

See Also

geom_boxplot

Examples

Run this code
# NOT RUN {
# Plot iris dataset by "Species" (discrete)
plot_boxplot(iris, by = "Species")

# Plot mtcars dataset by "mpg" (continuous)
plot_boxplot(mtcars, "mpg")

# Plot with preset ggplot2 themes
library(ggplot2)
plot_boxplot(iris, by = "Species", ggtheme = theme_light())
plot_boxplot(iris, by = "Species", ggtheme = theme_minimal(base_size = 20))

# Plot bar charts with customized theme components
plot_boxplot(iris,
by = "Species",
theme_config = list(
  "plot.background" = element_rect(fill = "yellow"),
  "aspect.ratio" = 1
))
# }

Run the code above in your browser using DataLab