O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

Bar graphs are perhaps the most commonly used kind of data visualization. They're

typically used to display numeric values (on the y axis) for various categories (on the

x axis). By default, bar graphs use a very dark grey color for the bars. To color the bars, use fill. Also, by default, there is no outline around the fill. To add an outline, use color.

We use stat= "identity" to denote that the y variable is a column in the dataset, whereas stat = "bin" is used when the variable is not a column in the dataset. Default is count data when you set stat = "bin".

geom_bar(show.legend = TRUE, stat = "identity", fill="lightblue", colour="black)

In large datasets, we often gain good insights by examining how different segments  ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required