statDensity: creates a ggplot object showing a densityplot

View source: R/generalStat.R

statDensityR Documentation

creates a ggplot object showing a densityplot

Description

creates a ggplot object showing a densityplot

Usage

statDensity(
  data,
  column = 1,
  outlineColor = "black",
  fillColor = "red",
  alpha = 1,
  variableName = "variable",
  vertical = FALSE,
  xLabel = ifelse(!is.Class(data, "data.frame"), NA, ifelse(is.character(column),
    paste(column, collapse = ""), paste(colnames(data)[column], collapse = ", "))),
  yLabel = "Probability Density",
  title = NA,
  titleDefault = paste(c("Distribution of ", ifelse(!is.character(column), "", column)),
    collapse = ""),
  removeNA = TRUE,
  xAxis = TRUE,
  yAxis = TRUE,
  xDefault = TRUE,
  xLimits = c(0, NA),
  xSymmetric = FALSE,
  xSymmetricExpand = 0.05,
  xCentered = FALSE,
  xMedian = FALSE,
  xDeviations = 4,
  gridLines = TRUE,
  gridLinesX = TRUE,
  gridLinesY = TRUE,
  showLegend = TRUE,
  legend.position = "bottom",
  ...
)

Arguments

data

the data tp 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 defines which column(s) is/are to be used

column

defines which column(s) is/are to be used for the densityplot. Can be integer or character (column name(s))

outlineColor

defines the color of the line around the densityplot

fillColor

defines the color of the densityplots 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

defines the see-through factor value of tje density plot

variableName

sets the 'combined' name of the columns (IF there is more than one!)

vertical

if TRUE, flips x- and 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

titleDefault

will be combined with the xLabel to be used as title if title == NA

removeNA

if TRUE, the NA 'values' in the vector will be removed prior to plotting. @note this has consquence that ROWS will be removed when using multiple columns with data.frame's

xAxis

defines if the x-axis is shown

yAxis

defines if the x-axis is shown

xDefault

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

xLimits

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

xSymmetric

if TRUE then the range of x-axis will be adjusted to be equal on both the left and the right side of the center (transformed x = 0)

xSymmetricExpand

allows for padding around data (x-axis), 0.05 means 5 percent (pre-transformation) extra wide x-axis range

xCentered

if TRUE, the plot will be 'cemtered' around the either the mean or median x-value

xMedian

if TRUE then median and mean absolute deviation (mad) are used for centering the plot along the x-axis; if FALSE then the mean and tge standard deviation are used

xDeviations

defines how many deviations the range of the x-axis may differ from the mean or median. Range will be either (median-xDeviations*mad ,median+xDeviations**mad) or (mean - xDeviations*sd,mean + xDeviations*sd)

gridLines

if TRUE then gridlines are shown

gridLinesX

if TRUE then vertical gridlines are shown (set gridLines to FALSE when using this)

gridLinesY

if TRUE then horizontal gridlines are shown (set gridLines to FALSE when using this)

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.