statDensityMultiple: generates a ggplot object which shows several density plots...

View source: R/generalStat.R

statDensityMultipleR Documentation

generates a ggplot object which shows several density plots in one

Description

generates a ggplot object which shows several density plots in one

Usage

statDensityMultiple(
  data,
  column = 1:ncol(data),
  melted = FALSE,
  varColumn = NA,
  varToChar = FALSE,
  sampleSize = NA,
  removeNA = TRUE,
  meltOrder = NA,
  newNames = NA,
  outlineColor = "black",
  fillColor = NA,
  alpha = 1,
  position = "identity",
  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 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 bars

fillColor

defines the color of the bars themselves. If a multi-column data.frame is plotted, the same number as the number of columns used should be used. If not the same number, then the graph will revert to default colors of ggplot

alpha

alpha ('see through' value) of the histogram bars

position

defines the positioning of the histogram bars with regard to each other. Options are 'identity','dodge' and 'stack'

vertical

defines wether the ggplot object's x- and y-axis should be swapped (essentially a 90 degree rotation)

xAxis

defines if the x-axis is shown

yAxis

defines if the x-axis is shown

yDefault

this defines if default y-sxis limits should be used or not, see also graphAdjust() for info

yLimits

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

xLabel

sets x-axis title

yLabel

set y-axos title

title

sets title of graph, if NA then the titleDefault will be used

legend.title

sets title of the legend (default NA)

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.