Description Usage Arguments Value Author(s) References See Also Examples
Easy barplot plot with R package ggplot2
1 2 3 |
data |
data.frame or a numeric vector. Columns are variables and rows are observations. |
xName |
The name of column containing x variable (i.e groups). Default value is NULL. |
yName |
The name of column containing y variable. If yName=NULL, data should be a numeric vector. |
groupName |
The name of column containing group variable. This variable is used to color plot according to the group. |
groupColors |
Color of groups. groupColors should have the same length as groups. |
brewerPalette |
This can be also used to indicate group colors. In this case the parameter groupColors should be NULL. e.g: brewerPalette="Paired". |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
... |
Other arguments passed on to ggplot2.customize custom function or to geom_bar functions from ggplot2 package. |
a ggplot
Alboukadel Kassambara <alboukadel.kassambara@gmail.com>
http://www.sthda.com
ggplot2.lineplot, ggplot2.histogram
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #data
df <- data.frame(time = factor(c("Lunch","Dinner"), levels=c("Lunch","Dinner")),
total_bill = c(14.89, 17.23))
#plot
ggplot2.barplot(data=df, xName="time", yName='total_bill',
mainTitle="Plot of total bill\n per time of day",
xtitle="Time of day", ytitle="Total bill")
#Or use this
plot<-ggplot2.barplot(data=df, xName="time", yName='total_bill')
plot<-ggplot2.customize(plot, mainTitle="Plot of total bill\n per time of day",
xtitle="Time of day", ytitle="Total bill")
print(plot)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.