From the course: R Essential Training: Wrangling and Visualizing Data

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Creating histograms

Creating histograms

From the course: R Essential Training: Wrangling and Visualizing Data

Start my 1-month free trial

Creating histograms

- [Instructor] When you have something that you're counting or measuring, that is, when you have a quantitative variable, probably the most helpful graph you can make is a histogram or a bell curve. And we can do this using ggplot. Let's start by loading up some packages. And then what I'm going to do is I'm going to first show you, not a data chart, but a probability density function. We're just going to make a bell curve, just the curve itself. I'm going to do this by using ggplot and then data frame, and then I'm saying start from negative four and go to positive four, and we're just going to make a graph of x. Now, this really just sets out what the background is. We're going to save that into P for probability. And then I'm going to add stat function, the function is equal to d normal, the density of the normal distribution. Size means how thick to make the line. Here is a color, that's blue. We're going to put…

Contents