Description Usage Arguments Value Author(s) Examples
View source: R/create.barplot.R
Create a barplot from a dataframe based on ggplot2's geom_bar().
1 |
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 |
ggplot object
Richard de Borja <richard.deborja@sickkids.ca>
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')
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.