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

Unlock this course with a free trial

Join today to access over 24,100 courses taught by industry experts.

heatmap

heatmap

- [Instructor] Heat maps are a great way to find outliers in a data set, and R provides a heat map command, so let's take a little bit of time to learn how R implements this very useful plot. The first thing to understand is that heat maps in R can only be done on a matrix. They cannot be done on a data frame, so your data set must be a matrix. In line one, two, and three you can see that I've created a matrix called mySimpleData, and in lines five and six I've placed two outliers that we're going to try to find. Let's take a quick look at mySimpleData just to see what it looks like. Here it is, mySimpleData, and I hit return, and then return again, and you can see that the mySimpleData matrix contains four columns, wheat, rye, quinoa, and rice, and rows corresponding to months of the year. Notice that the numbers are all numeric, there aren't characters and there aren't factors, and that's required by matrix. In a matrix all the values are one class. So, let's create a heat map for…

Contents