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

Creating histograms

Generate a histogram for acceleration:

> hist(acceleration) 

R determines the various properties of the generated graph (such as bin sizes, axes scales, axes titles, chart title, bar colors, and so on) automatically. The following diagram shows the output of the preceding command:

You can customize everything. The following code shows some options:

> hist(acceleration, col="blue", xlab = "acceleration",     main = "Histogram of acceleration", breaks = 15) 

The histogram of acceleration can be seen in the following diagram:

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