Book Image

R Data Visualization Cookbook

Book Image

R Data Visualization Cookbook

Overview of this book

Table of Contents (17 chapters)
R Data Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Constructing a radial plot


The main idea behind a radial plot is to project the data as a distance from the centre in a circular form. Radial plots are not observed very often but are good tools to visualize monthly time series data. In this recipe, we will use oil prices in USA as an example to construct the radial plot.

Getting ready

In order to create a radial plot, we need to load the plotrix package.

How to do it…

We can install the package as well as load the library in our active R session by typing the following lines in the R console window:

install.packages("plotrix")
library(plotrix)

The data consists of 21 years of monthly data for oil prices in USA. We import our data in R using the read.csv() function. Note that R will search for the file in our current R directory:

oil = read.csv("oil.csv")

We can now construct a radial plot by implementing it in R via the radial.plot() function:

radial.plot(oil[,21],rp.type="p",lwd =3,line.col="blue",labels=oil$Month, clockwise = TRUE, start = 1.5...