Book Image

R Graphs Cookbook Second Edition

Book Image

R Graphs Cookbook Second Edition

Overview of this book

Table of Contents (22 chapters)
R Graphs Cookbook
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Summarizing multivariate data in a single heat map


In the preceding couple of recipes, we looked at representing a matrix of data along two axes on a heat map. In this recipe, we will learn how to summarize multivariate data using a heat map.

Getting ready

We are only using the base graphics functions for this recipe. So, just open up the R prompt and type in the following code. We will use the nba.csv example dataset for this recipe. So, let's first load it:

nba <- read.csv("nba.csv")

This example dataset, which shows some statistics on the top scorers in NBA basketball games has been taken from a blog post on FlowingData (see http://flowingdata.com/2010/01/21/how-to-make-a-heatmap-a-quick-and-easy-solution/ for details). The original data is from the databaseBasketball.com website (http://databasebasketball.com/). We will use our own code to create a similar heat map showing player statistics.

We will use the RColorBrewer library for a nice color palette, so let's load it:

library(RColorBrewer...