Introduction to R Programming

Bar Chart in R

Bar Chart in R

Bar Charts are horizontal or vertical bars used to show comparisons between categorical values. They represent length, frequency, or proportion of categorical values.

Syntax: barplot(x)

Example

#vertical bar chart
counts <- table(employee$role)
barplot(counts)

#horizontal bar chart 
barplot(counts, horiz=TRUE)

Apart from horizontal and vertical bar chart, you can create stacked and grouped bar chart using R.

Leave a Reply