statBoxPlotMultiple: creates a ggplot object showing a boxplot of multiple columns

View source: R/generalStat.R

statBoxPlotMultipleR Documentation

creates a ggplot object showing a boxplot of multiple columns

Description

creates a ggplot object showing a boxplot of multiple columns

Usage

statBoxPlotMultiple(
  data,
  column = 1:ncol(data),
  melted = FALSE,
  varColumn = NA,
  varToChar = FALSE,
  sampleSize = NA,
  removeNA = TRUE,
  meltOrder = NA,
  newNames = NA,
  outlineColor = "black",
  fillColor = NA,
  jitter = 0.05,
  alpha = 0.5,
  size = 3,
  shape = 16,
  jitterFill = "black",
  whiskerWidth = 0.5,
  boxWidth = 0.5,
  vertical = FALSE,
  xAxis = TRUE,
  yAxis = TRUE,
  yDefault = TRUE,
  yLimits = c(0, NA),
  xLabel = "",
  yLabel = "",
  title = "",
  showMean = TRUE,
  meanShape = 23,
  meanColor = "black",
  meanFill = "orange",
  meanSize = 5,
  legend.title = NA,
  showLegend = TRUE,
  legend.position = "bottom",
  ...
)

Arguments

data

the data to be used, can be a numeric/character/etc vector or data.frame like (or tibble etc). If it is data.frame or similar the column argument defines which column is to be used

column

defines which columns are to be used. Can be integer or character (column name), note that if both (character) column and yLabel are defined, column is used as label for the Y-axis. If not defined, then all columns of the data.frame will be used.

melted

boolean that defines whether the specified columns still need to be melted into a single column for a graph. If melted = TRUE then the argument "column" should be a single column!

varColumn

this boolean argument is only used in case melted = TRUE. It specifies the column to be used as variable name column

varToChar

default FALSE, gnored if melted = FALSE. Specifies if the variable name column should be converted into a character vector (need discrete values)

sampleSize

allows to the use of a sample of the data to be used for the boxplot. By default sampleSize = NA, in which case all data is used

removeNA

if TRUE, the NA 'values' in the vector will be removed prior to plotting. @note this will remove warning messages and errors

meltOrder

numeric vector which allows to define the order in which columns should be melted onto each other. Normally the order is the same as the column order specifoed (default NA), but this parameter allows some extra flexibility. Be aware that columns are first melted and then newNames is applied (if not NA)

newNames

redefines the names of the different data columns. In principle this could be done before this function is called, but using this argument circumvents some issues with column names. Note that the length of this argument (character vector) should be the same as the number of columns, otherwise it will be ignored

outlineColor

defines the color of the line around the box

fillColor

defines the color of the boxes themselves. @Note: if the number of colors does not match the number of columns then ggplot2 default colors will be used

jitter

if NA, then the data points will not be shown (only outliers!), otherwise it adds a random value to the x-values of the data points plotted. Note: If set to 0 then they will be located on a straight line

alpha

alpha ('see through' value) of the data (jitter) points

size

size of the data (jitter) points

shape

shape of the data (default = 16), see vignette ggplot2::ggplot2-specs

jitterFill

defines color of the jitter (single color!)

whiskerWidth

defines the width of the whiskers (0-1)

boxWidth

defines the width of the box (0-1)

vertical

if TRUE, flips x- and y-axis

xAxis

defines if the x-axis is shown

yAxis

defines if the x-axis is shown

yDefault

default is set to TRUE, together with yLimits, this can be used to define the exact range of the Y-axis

yLimits

default = c(0,NA), together with yLimits, this can be used to define the exact range of the Y-axis

xLabel

set x-axis title

yLabel

set y-axis title

title

sets title of graph

showMean

defines if the mean value of the data should be shown

meanShape

shape of the mean symbol (default = 23)

meanColor

color of the line around the mean symbol

meanFill

fill color of the shape of the mean symbol

meanSize

size of the mean symbol

legend.title

if not NA, then to give a non-default name to the legend

showLegend

defines if the legend is to be shown or not

legend.position

defines where a legend is to be placed

...

can be used to pass on other arguments to graphAdjust() (like xLimits, xExpand, etc)

Value

a ggplot object

Note

box itself: bottom = 25 lower whisker = 25 upper whisker= 75 IQR = (75


BenBruyneel/BBPersonalR documentation built on Aug. 23, 2024, 8:28 p.m.