statHist | R Documentation |
creates a ggplot object showing a histogram
statHist(
data,
column = 1,
binwidth = NULL,
bins = NULL,
statCount = FALSE,
variableName = "variable",
removeNA = TRUE,
outlineColor = "white",
outlineWidth = 0.5,
outlineType = "solid",
fillColor = "red",
xLabel = ifelse(!is.Class(data, "data.frame"), NA, ifelse(is.character(column),
paste(column, collapse = ", "), paste(colnames(data)[column], collapse = ", "))),
yLabel = "Frequency",
title = NA,
titleDefault = paste(c("Histogram of ", ifelse(!is.character(column), "", column)),
collapse = ""),
xAxis = TRUE,
yAxis = TRUE,
xDefault = TRUE,
xLimits = c(0, NA),
xSymmetric = FALSE,
xSymmetricExpand = 0.05,
xCentered = FALSE,
xMedian = FALSE,
xDeviations = 4,
showLegend = TRUE,
legend.position = "bottom",
vertical = FALSE,
...
)
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 histogram. Can be integer or character (column name(s)) |
binwidth |
defines width of the 'bins' of the histogram, if NULL (default), then it will be set automatically (with a warning). This setting is ignored in case statCount is set tp TRUE |
bins |
defines the number of 'bins' of the histogram, overriden by binwidth |
statCount |
set to TRUE if the data is not numerical |
variableName |
sets the 'combined' name of the columns (IF there is more than one!) |
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 |
outlineColor |
defines the color of the line around the bars |
outlineWidth |
defines the width of the line around the bars |
outlineType |
defines the linetype 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 |
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 |
xAxis |
defines if the x-axis is shown |
yAxis |
defines if the x-axis is shown |
xDefault |
this defines if default x-sxis limits should be used or not, see also graphAdjust() for info |
xLimits |
default = c(0,NA), together with xDefault, this can be used to define the exact range of the x-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 |
xSymmetricExpand |
allows for padding around data (x-axis), 0.05 means 5 percent 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 the 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) |
showLegend |
defines if the legend is to be shown or not |
legend.position |
defines where a legend is to be placed |
vertical |
if TRUE, flips x- and y-axis |
... |
can be used to pass on other arguments to graphAdjust() (like xLimits, xExpand, etc) |
a ggplot object
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.