From the course: R for Data Science: Lunch Break Lessons

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Histogram

Histogram

- [Instructor] Histograms are tremendously useful ways to visualize data and R provides a ridiculously easy way to produce histograms. Let's take a look at 'em. The easiest way to do it is just to simply type hist parentheses and let's use chickweight and we'll graph a histogram of the weight of chickens so I hit return and I am immediately presented with a histogram of the chick weight and you can see across the bottom is the weight, across the left is frequency, the number of elements at that particular weight and hist has provided us with what it thinks are reasonable breaks for the bars. There are ways to modify this particular histogram so let's go in and take a look, we can change some of the graphic elements of it. Here's our previous command, hist chickweight dollar sign weight and we can change the density of the bars. Density equals let's type in 30 and that'll produce a line across each of the bars. It just gives us a little bit more visual detail on where those bars are…

Contents