plot_boxplot: Plot box-plots of numerical variables

Description Usage Arguments Examples

Description

This function creates nicely formatted, standardised box-plots.

Usage

1
2
3
4
5
6
plot_boxplot(df, x, y, fill = NULL, facet = NULL, ticks = 10,
  angle = 0, title = TRUE, subtitle = NULL, caption = NULL,
  lab_x = "Level", lab_y = "Value range", legend = TRUE,
  vline = c(NaN), alpha = 0.7, quantile_low = 0.025,
  quantile_high = 0.975, palette = "cartography",
  theme_type = "grey")

Arguments

df

A data frame

x

A categorical variable for the x axis groupings

y

A numerical variable for the y axis levels

fill

Select an additional grouping variable to be used for plotting. Defaults to NULL

facet

Select an additional faceting variable to create facets. Defaults to NULL

ticks

Select the number of ticks on the y axis. Defaults to 10

angle

Select the rotation angle for the x axis labels. Defaults to 0

title

Should the plot title appear automatically. Defaults to TRUE

subtitle

Text that is displayed on the subtitle. Defaults to NULL

caption

Text that is displayed on the caption. Defaults to NULL

lab_x

Text that is displayed on the x axis. Defaults to "Level"

lab_y

Text that is displayed on the y axis. Defaults to "Value range"

legend

Should the plot legend appear automatically. Defaults to TRUE

vline

Should any horizontal lines be added to the plot. Defaults to c(NaN)

alpha

Select plot fill transparency. Defaults to .7

quantile_low

Select lower percentile for outliers exclusion. Defaults to 2.5%

quantile_high

Select upper percentile for outliers exclusion. Defaults to 97.5%

palette

Select a color palette from colors available in the select_palette function or provide your own as a nammed vector

theme_type

Select a theme type from themes available in the aider_theme function

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
data <- recipes::credit_data %>%
  first_to_lower()

data %>%
  plot_boxplot(x = marital,
               y = time)

data %>%
  plot_boxplot(x = marital,
               y = time,
               fill = marital)

data %>%
  plot_boxplot(x = marital,
               y = time,
               fill = marital,
               facet = job)

data %>%
  plot_boxplot(x = marital,
               y = time,
               fill = marital,
               facet = job,
               ticks = 5,
               vline = 45,
               angle = 45,
               alpha = .7)

konradsemsch/aider documentation built on May 22, 2019, 2:40 p.m.