create.barplot: Create a barplot.

Description Usage Arguments Value Author(s) Examples

View source: R/create.barplot.R

Description

Create a barplot from a dataframe based on ggplot2's geom_bar().

Usage

1
create.barplot(data = NULL, x = NULL, y = NULL, fill = NULL, group = NULL, group.col = FALSE, group.row = FALSE, rotate = FALSE, width = 0.9, ylab = NULL, xlab = NULL, yaxis.log.scale = FALSE, xaxis.log.scale = FALSE, theme = NULL)

Arguments

data

Dataframe containing data to plot

x

Dataframe element to plot as the x-axis

y

Dataframe element to plot on the y-axis

fill

Dataframe element to use as the colour to fill the bars

group

Dataframe element to use to group bars using facet_grid()

group.col

Boolean to group data for facet_grid() by column

group.row

Boolean to group data for facet_grid() by row

rotate

Boolean to rotate the plot

width

Bin width

ylab

Text to label the y-axis

xlab

Text to label the x-axis

yaxis.log.scale

Boolean to show yaxis in log scale

xaxis.log.scale

Boolean to show xaxis in log scale

theme

Theme function to use for the plot

Value

ggplot object

Author(s)

Richard de Borja <richard.deborja@sickkids.ca>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# set the cylinders as factors
mtcars$cyl <- factor(mtcars$cyl)

# create a simple barplot
create.barplot(data = mtcars, x = 'cyl')

# add x-axis and y-axis labels
create.barplot(
  data = mtcars,
  x = 'cyl',
  xlab = 'Number of Cylinders',
  ylab = 'Count'
  )

# use the theme theme_bw() instead of the default barplot theme
create.barplot(
  data = mtcars,
  x = 'cyl',
  xlab = 'Number of Cylinders',
  ylab = 'Count',
  theme = theme_bw(base_size = 24, base_family = 'Helvetica')
  )

rdeborja/plotting.general documentation built on May 27, 2019, 3:05 a.m.