Professional Documents
Culture Documents
• Syntax
• The basic syntax to create a bar-chart in R is −
• barplot(H,xlab,ylab,main, names.arg,col)
• Following is the description of the parameters used −
• H is a vector or matrix containing numeric values used in bar
chart.
• xlab is the label for x axis.
• ylab is the label for y axis.
• main is the title of the bar chart.
• names.arg is a vector of names appearing under each bar.
• col is used to give colors to the bars in the graph.
Ggplot2 in R
• ggplot2 is a R package dedicated to data
visualization. It can greatly improve the quality
and aesthetics of your graphics, and will make
you much more efficient in creating them.
• ggplot2 allows to build almost any type of
chart. The R graphallery focuses on it so
almost every section there starts with
Ggplot2 in R
• Elements of ggplot2
• Let’s start by installing the ggplot2 package by
calling install.packages(“ggplot2”)
• install.packages("ggplot2")Now we need to
load the package by using
the library() function.
• library(ggplot2)