statViolinPlotMultiple: creates a ggplot object showing a violin plots of multiple...

View source: R/generalStat.R

statViolinPlotMultipleR Documentation

creates a ggplot object showing a violin plots of multiple columns

Description

creates a ggplot object showing a violin plots of multiple columns

Usage

statViolinPlotMultiple(
  data,
  column = 1:ncol(data),
  melted = FALSE,
  varColumn = NA,
  varToChar = FALSE,
  sampleSize = NA,
  removeNA = TRUE,
  meltOrder = NA,
  newNames = NA,
  outlineColor = "black",
  fillColor = NA,
  outlineSize = 0.5,
  outlineType = "solid",
  violinAlpha = 1,
  scale = c("area", "count", "width")[1],
  trim = TRUE,
  bandwidth = 1,
  quantiles = NULL,
  vertical = FALSE,
  xAxis = TRUE,
  yAxis = TRUE,
  yDefault = TRUE,
  yLimits = c(0, NA),
  xLabel = "",
  yLabel = "",
  title = "",
  legend.title = NA,
  showLegend = TRUE,
  legend.position = "bottom",
  ...
)

Arguments

data

the data to be plotted, 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 for the boxplot. 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 'violin'

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

outlineSize

defines the width of the line around the 'violin'

outlineType

defines the linetype of the line around the 'violin'

violinAlpha

defines the alpha ('see through' value) the 'violin'

scale

default = "area", other valid values are "count" and "width". if "area" (default), all violins have the same area (before trimming the tails). If "count", areas are scaled proportionally to the number of observations. If "width", all violins have the same maximum width. @note taken from ?geom_violin, there is no sense in setting this argument for a single violin plot

trim

If TRUE (default), trim the tails of the violins to the range of the data. If FALSE, don't trim the tails. @note taken from ?geom_violin

bandwidth

defines the 'adjust' parameter, which is the adjustment of smoothing bandwidth. 1/2 means half of default bandwidth –> makes the outline more 'jagged'

quantiles

draws lines at the specified quantiles, eg c(0.25,0.5,0.25). If NULL, nothing is drawn

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

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


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