ggplot2.barplot: Easy barplot plot with R package ggplot2

Description Usage Arguments Value Author(s) References See Also Examples

Description

Easy barplot plot with R package ggplot2

Usage

1
2
3
ggplot2.barplot(data, xName = NULL, yName = NULL, groupName = NULL,
  groupColors = NULL, brewerPalette = NULL, position = position_stack(),
  ...)

Arguments

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.

Value

a ggplot

Author(s)

Alboukadel Kassambara <alboukadel.kassambara@gmail.com>

References

http://www.sthda.com

See Also

ggplot2.lineplot, ggplot2.histogram

Examples

 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)

YTLogos/easyGgplot2 documentation built on May 3, 2019, 9:03 p.m.