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

Visualizing time series as calendar heat maps


In this recipe, we will learn how to make intuitive heat maps in a calendar format to summarize time series data.

Getting ready

In this recipe, we will use a custom function called calendarHeat() written by Paul Bleicher (released as open source under the GPL license). So, let's first load the source code of the function (available from the downloads area of the book's website):

source("calendarHeat.R")

We are going to use the google.csv example dataset, which contains stock price data for Google (ticker GOOG). Let's load it:

stock.data <- read.csv("google.csv")

The calendarHeat() function also makes use of the chron library, which has to be installed and loaded using the following code:

install.packages("chron")
library("chron")

How to do it...

Let's visualize the adjusted closing price of the Google stock in a calendar heat map:

calendarHeat(dates=stock.data$Date, 
values=stock.data$Adj.Close, 
varname="Google Adjusted Close")

How it works...

We used...