statBarPlot | R Documentation |
generates a simple barplot of data with id's in one column (x-axis values) and the y-axis values in the varColumn
statBarPlot(
data,
idColumn = 1,
varColumn = 2:ncol(data),
sampleSize = NA,
removeNA = FALSE,
variableName = "Variable",
valueName = "Value",
barPosition = ggplot2::position_dodge(),
fillColors = NA,
fillPalette = NA,
outlineColor = 0,
outlineType = "solid",
outlineWidth = 1,
fillAlpha = 1,
vertical = FALSE,
yAxis = TRUE,
yDefault = TRUE,
yLimits = c(0, NA),
ySpace = 0.1,
xLabel = idColumn,
yLabel = valueName,
title = "",
gridLines = TRUE,
showLegend = TRUE,
legend.position = "bottom",
returnData = FALSE,
...
)
data |
data.frame with 1 (numeric) column to be used as x-values and 1 or more columns to be used as bars (y-axis) |
idColumn |
defines which column in the data is to be used as id of the bars in the barplot |
varColumn |
one or more columns with numeric data, defining the height of the bars in the barplot |
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 |
variableName |
allows setting of the 'name' of the varColumns (x-value o/t bars, eg concentration) |
valueName |
allows for setting of the name of the y-axis (eg signal) |
barPosition |
sets the dodging etc of the bars in the barplot, see ?ggplot2::position_dodge for more info |
fillColors |
sets the colors to be used for the bars |
fillPalette |
to set more subtle colors for the bars, examples: "Blues", "Greens", etc |
outlineColor |
sets the outline color of the bars |
outlineType |
sets the linetype for the outline of the bars |
outlineWidth |
sets the width of the outline of the bars |
fillAlpha |
sets the alpha (shine through) value of the fill colors of the bars |
vertical |
if TRUE then plot will be rotated 90 degrees |
yAxis |
if TRUE then the y-Axis will be shown |
yDefault |
if TRUE then default y-axis is used (based on the values in the barplot), if FALSE then the yLimits parameter is used to set the y-Axis range |
yLimits |
two value numeric vector, specifying the minimum and maximum value of the range of the y-Axis |
ySpace |
specifies how much space there should be between the maximum y-value in the barplot and the top of the plot. Value of 0 is no space, a value of 0.1 is equivalent to extending the y-range 10 percent |
xLabel |
specifies the label on the x-axis |
yLabel |
specifies the label on the y-axis |
title |
specifies the title of the barplot |
gridLines |
if TRUE then gridlines are shown |
showLegend |
if TRUE then the legend is shown |
legend.position |
defines the place of the legend (default = "bottom") |
returnData |
if TRUE then a list with 2 elements is returned. The first element is the data.frame used to generate the graph and the second element is the graph itself |
... |
can be used to pass on other arguments to graphAdjust() (like xLimits, xExpand, etc) example code: ll <- data.frame(id = c(1,2,3,4), P1 = c(1,2,3,2), P2 = c( 4.0, 5.0,10.0, 5.5), P3 = c(10, 2,23, 5), P4 = c(10.0, 2.0, 6.7, 3.0)) statBarPlot(ll, idColumn = "id", varColumn = 2:5, returnData = T) |
a ggplot object or a list
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.