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.

cdplot

cdplot

- [Instructor] The R language has quite a lot of built in graphics capabilities, not only the ability to export to different file formats. But also the ability to create different types of plots and graphs. A conditional density plot is one of those and let's take a look at how we can create that using standard base R functionality. First of all we need some data, so let's grab the data, ChickWeight and then let's say that I want to given a certain amount of time, figure out how much a chick should weigh. So a conditional density plot requires a factor, that's the first thing we need to create. So I'm going to create a factor, inside of a vector called ThreeWeights and into it I'm going to use the cut functionality that we talked about earlier to cut ChickWeight, weight into three buckets and I'm going to label those buckets as 34, 148, and 260 and those values I came across earlier with doing some experimentation about how to properly label the resulting graph. So you can experiment…

Contents