box_plot {r2spss}R Documentation

Box Plots

Description

Draw box plots of variables in a data frame, including box plots for groups of observations and box plots for separate variables. The plots thereby mimic the look of SPSS graphs.

Usage

box_plot(
  data,
  variables,
  group = NULL,
  cut.names = NULL,
  style = c("T", "whiskers"),
  coef = c(1.5, 3),
  outlier.shape = c(1, 42),
  version = r2spss_options$get("version"),
  ...
)

Arguments

data

a data frame containing the variables to be plotted.

variables

a character vector specifying separate variables to be plotted. If group is not NULL, only the first variable is used and box plots of groups of observations are drawn instead.

group

an character string specifying a grouping variable, or NULL for no grouping.

cut.names

a logical indicating whether to cut long variable names or group labels to 8 characters. The default is TRUE for box plots of separate variables, but FALSE for box plots of groups of observations (which mimics SPSS behavior).

style

a character string specifying the box plot style. Possible values are "T" for T-bars (the default) or "whiskers" for simple whiskers.

coef

a numeric vector of length 2 giving the multipliers of the interquartile range for determining intermediate and extreme outliers, respectively.

outlier.shape

an integer vector of length 2 giving the plot symbol for intermediate and extreme outliers, respectively.

version

a character string specifying whether the plot should mimic the look of recent SPSS versions ("modern") or older versions (<24; "legacy").

...

additional arguments to be passed down, in particular aesthetics (see geom_boxplot).

Value

An object of class "ggplot", which produces a box plot when printed.

Author(s)

Andreas Alfons

Examples

## paired sample
# load data
data("Exams")

# plot grades on regular and resit exams
box_plot(Exams, c("Regular", "Resit"))


## independent samples

# load data
data("Eredivisie")
# log-transform market values
Eredivisie$logMarketValue <- log(Eredivisie$MarketValue)

# plot log market values of Dutch and Foreign players
box_plot(Eredivisie, "logMarketValue", group = "Foreign")


[Package r2spss version 0.3.2 Index]