Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
R Data Visualization Cookbook
R Data Visualization Cookbook

R Data Visualization Cookbook: Over 80 recipes to analyze data and create stunning visualizations with R

eBook
£7.99 £28.99
Paperback
£35.99
Subscription
Free Trial
Renews at £16.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

R Data Visualization Cookbook

Chapter 1. A Simple Guide to R

In this chapter, we will cover the following recipes:

  • Installing packages and getting help in R
  • Data types in R
  • Special values in R
  • Matrices in R
  • Editing a matrix in R
  • Data frames in R
  • Editing a data frame in R
  • Importing data in R
  • Exporting data in R
  • Writing a function in R
  • Writing if else statements in R
  • Basic loops in R
  • Nested loops in R
  • The apply, lapply, sapply, and tapply functions
  • Using par to beautify a plot in R
  • Saving plots

Installing packages and getting help in R

If you are a new user and have never launched R, you must definitely start the learning process by understanding the use of install.packages(), library(), and getting help in R. R comes loaded with some basic packages, but the R community is rapidly growing and active R users are constantly developing new packages for R.

As you read through this cookbook, you will observe that we have used a lot of packages to create different visualizations. So the question now is, how do we know what packages are available in R? In order to keep myself up-to-date with all the changes that are happening in the R community, I diligently follow these blogs:

  • Rblogger
  • Rstudio blog

There are many blogs, websites, and posts that I will refer to as we go through the book. We can view a list of all the packages available in R by going to http://cran.r-project.org/, and also http://www.inside-r.org/packages provides a list as well as a short description of all the packages.

Getting ready

We can start by powering up our R studio, which is an Integrated Development Environment (IDE) for R. If you have not downloaded Rstudio, then I would highly recommend going to http://www.rstudio.com/ and downloading it.

How to do it…

To install a package in R, we will use the install.packages() function. Once we install a package, we will have to load the package in our active R session; if not, we will get an error. The library() function allows us to load the package in R.

How it works…

The install.packages() function comes with some additional arguments but, for the purpose of this book, we will only use the first argument, that is, the name of the package. We can also load multiple packages by using install.packages(c("plotrix", "RColorBrewer")). The name of the package is the only argument we will use in the library() function. Note that you can only load one package at a time with the library() function unlike the install.packages() function.

There's more…

It is hard to remember all the functions and their arguments in R, unless we use them all the time, and we are bound to get errors and warning messages. The best way to learn R is to use the active R community and the help manual available in R.

To understand any function in R or to learn about the various arguments, we can type ?<name of the function>. For example, I can learn about all the arguments related to the plot() function by simply typing ?plot or ?plot() in the R console window. You will now view the help page on the right side of the screen. We can also learn more about the behavior of the function using some of the examples at the bottom of the help page.

If we are still unable to understand the function or its use and implementation, we could go to Google and type the question or use the Stack Overflow website. I am always able to resolve my errors by searching on the Internet. Remember, every problem has a solution, and the possibilities with R are endless.

See also

Data types in R

Everything in R is in the form of objects. Objects can be manipulated in R. Some of the common objects in R are numeric vectors, character vectors, complex vectors, logical vectors, and integer vectors.

Data types in R

How to do it…

In order to generate a numeric vector in R, we can use the C() notation to specify it as follows:

x = c(1:5) # Numeric Vector

To generate a character vector, we can specify the same within quotes (" ") as follows:

y ="I am Home" # Character Vector

To generate a complex vector, we can use the i notation as follows:

c = c(1+3i) #complex vector

A list is a combination of a character and a numeric vector and can be specified using the list() notation:

z = list(c(1:5),"I am Home") # List

Special values in R

R comes with some special values. Some of the special values in R are NA, Inf, -Inf, and NaN.

Special values in R

How to do it…

The missing values are represented in R by NA. When we download data, it may have missing data and this is represented in R by NA:

z = c( 1,2,3, NA,5,NA) # NA in R is missing Data

To detect missing values, we can use the install.packages() function or is.na(), as shown:

complete.cases(z) # function to detect NA
is.na(z) # function to detect NA

To remove the NA values from our data, we can type the following in our active R session console window:

clean <- complete.cases(z)
z[clean] # used to remove NA from data

Please note the use of square brackets ([ ]) instead of parentheses.

In R, not a number is abbreviated as NaN. The following lines will generate NaN values:

##NaN
0/0
m <- c(2/3,3/3,0/0)
m

The is.finite, is.infinite, or is.nan functions will generate logical values (TRUE or FALSE).

is.finite(m)
is.infinite(m)
is.nan(m)

The following line will generate inf as a special value in R:

## infinite
k = 1/0

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

How it works…

complete.cases(z) is a logical vector indicating complete cases that have no missing value (NA). On the other hand, is.na(z) indicates which elements are missing. In both cases, the argument is our data, a vector, or a matrix.

How it works…

R also allows its users to check if any element in a matrix or a vector is NA by using the anyNA() function. We can coerce or assign NA to any element of a vector using the square brackets ([ ]). The [3] input instructs R to assign NA to the third element of the dk vector.

Matrices in R

In this recipe, we will dive into R's capability with regard to matrices.

Matrices in R

How to do it…

A vector in R is defined using the c() notation as follows:

vec = c(1:10)

A vector is a one-dimensional array. A matrix is a multidimensional array. We can define a matrix in R using the matrix() function. Alternatively, we can also coerce a set of values to be a matrix using the as.matrix() function:

mat = matrix(c(1,2,3,4,5,6,7,8,9,10),nrow = 2, ncol = 5)
mat

To generate a transpose of a matrix, we can use the t() function:

t(mat) # transpose a matrix

In R, we can also generate an identity matrix using the diag() function:

d = diag(3) # generate an identity matrix

We can nest the rep () function within matrix() to generate a matrix with all zeroes as follows:

zro = matrix(rep(0,6),ncol = 2,nrow = 3 )# generate a matrix of Zeros
zro

How it works…

We can define our data in the matrix () function by specifying our data as its first argument. The nrow and ncol arguments are used to specify the number of rows and column in a matrix. The matrix function in R comes with other useful arguments and can be studied by typing ?matrix in the R command window.

The rep() function nested in the matrix() function is used to repeat a particular value or character string a certain number of times.

The diag() function can be used to generate an identity matrix as well as extract the diagonal elements of a matrix. More uses of the diag() function can be explored by typing ?diag in the R console window.

The code file provides a lot more functions that can used along with matrices—for example, functions related to finding a determinant or inverse of a matrix and matrix multiplication.

Editing a matrix in R

R allows us to edit (add, delete, or replace) elements of a matrix using the square bracket notation, as depicted in the following lines of code:

mat = matrix(c(1:10),nrow = 2, ncol = 5)
mat
mat[2,3]

How to do it…

In order to extract any element of a matrix, we can specify the position of that element in R using square brackets. For example, mat[2,3] will extract the element under the second row and the third column. The first numeric value corresponds to the row and the second numeric value corresponds to a column [row, column].

Similarly, to replace an element, we can type the following lines in R:

mat[2,3] = 16

To select all the elements of the second row, we can use mat[2, ]. If we do not specify any numeric value for a column, R will automatically assume all columns.

Data frames in R

One of the useful and widely used functions in R is the data.frame() function. Data frame, according to the R manual, is a matrix structure whose columns can be of differing types, such as numeric, logical, factor, or character.

How to do it…

A data frame in R is a collection of variables. A simple way to construct a data frame is using the data.frame() function in R:

data = data.frame(x = c(1:4), y = c("tom","jerry","luke","brian"))
data

Many times, we will encounter plotting functions that require data to be in a data frame. In order to coerce our data into a data frame, we can use the data.frame() function. In the following example, we create a matrix and convert it into a data frame:

mat = matrix(c(1:10), nrow = 2, ncol = 5)
data.frame(mat)

The data.frame() function comes with various arguments and can be explored by typing ?data.frame in the R console window. The code file under the title Data Frames – 2 provides additional functions that can help in understanding the underlying structure of our data. We can always get additional help by using the R documentation.

Editing a data frame in R

Once we have generated a data and converted it into a data frame, we can edit any row or column of a data frame.

How to do it...

We can add or extract any column of a data frame using the dollar ($) symbol, as depicted in the following code:

data = data.frame(x = c(1:4), y = c("tom","jerry","luke","brian"))
data$age = c(2,2,3,5)
data

In the preceding example, we have added a new column called age using the $ operator. Alternatively, we can also add columns and rows using the rbind() and cbind() functions in R as follows:

age = c(2,2,3,5)
data = cbind(data, age)

The cbind and rbind functions can also be used to add columns or rows to an existing matrix.

To remove a column or a row from a matrix or data frame, we can simply use the negative sign before the column or row to be deleted, as follows:

data = data[,-2]

The data[,-2] line will delete the second column from our data.

To re-order the columns of a data frame, we can type the following lines in the R command window:

data = data.frame(x = c(1:4), y = c("tom","jerry","luke","brian"))
data = data[c(2,1)]# will reorder the columns
data

To view the column names of a data frame, we can use the names() function:

names(data)

To rename our column names, we can use the colnames() function:

colnames(data) = c("Number","Names")

Importing data in R

Data comes in various formats. Most of the data available online can be downloaded in the form of text documents (.txt extension) or as comma-separated values (.csv). We also encounter data in the tab-delimited format, XLS, HTML, JSON, XML, and so on. If you are interested in working with data, either in JSON or XML, refer to the recipe Constructing a bar plot using XML in R in Chapter 10, Creating Applications in R.

How to do it...

In order to import a CSV file in R, we can use the read.csv() function:

test = read.csv("raw.csv", sep = ",", header = TRUE)

Alternatively, read.table() function allows us to import data with different separators and formats. Following are some of the methods used to import data in R:

How to do it...

How it works…

The first argument in the read.csv() function is the filename, followed by the separator used in the file. The header = TRUE argument is used to instruct R that the file contains headers. Please note that R will search for this file in its current directory. We have to specify the directory containing the file using the setwd() function. Alternatively, we can navigate and set our working directory by navigating to Sessions | Set working directory | Choose directory.

The first argument in the read.table() function is the filename that contains the data, the second argument states that the data contains the header, and the third argument is related to the separator. If our data consists of a semi colon (;), a tab delimited, or the @ symbol as a separator, we can specify this under the sep ="" argument. Note that, to specify a separator as a tab delimited, users would have to substitute sep = "," with sep ="\t" in the read.table() function.

One of the other useful arguments is the row.names argument. If we omit row.names, R will use the column serial numbers as row.names. We can assign row.names for our data by specifying it as row.names = c("Name").

Exporting data in R

Once we have processed our data, we need to save it to an external device or send it to our colleagues. It is possible to export data in R in many different formats.

How to do it…

To export data from R, we can use the write.table() function. Please note that R will export the data to our current directory or the folder we have assigned using the setwd() function:

write.table(data, "mydata.csv", sep=",")

How it works…

The first argument in the write.table() function is the data in R that we would like to export. The second argument is the name of the file. We can export data in the .xls or .txt format, simply by replacing the mydata.csv file extension with mydata.txt or mydata.xls in the write.table() function.

Writing a function in R

Most of the tasks in R are performed using functions. A function in R has the same utility as functions in Arithmetic.

Getting ready

In order to write a simple function in R, we must first open a new R script by navigating to File | New file.

How to do it…

We write a very simple function that accepts two values and adds them together. Copy and paste the code in the new blank R script:

add = function (x,y){
  x+y
}

How it works…

A function in R should be defined by function(). Once we define our function, we need to save it as a .r file. Note that the name of the file should be the same as the function; hence we save our function with name add.r.

In order to use the add() function in the R command window, we need to source the file by using the source() function as follows:

source('<your path>/add.R')

Now, we can type add(2,15) in the R command window. You get 17 printed as an output.

The function itself takes two arguments in our recipe but, in reality, it can take many arguments. Anything defined inside curly braces gets executed when we call add(). In our case, we request the user to input two variables, and the output is a simple sum.

See also

  • Functions can be helpful in performing repetitive tasks such as generating plots or perform complicated calculations. Felix Schönbrodt has implemented visually weighted watercolor plots in R using a function on his blog at http://www.nicebread.de/visually-weighted-watercolor-plots-new-variants-please-vote/.
  • We can generate similar plots simply by copying the function created by Felix in our R session and executing it. The plotting function created by Felix also provides users with different ways in which the R function's ability could be leveraged to perform repetitive tasks.

Writing if else statements in R

We often use if statements in MS Excel, but we can also write a small code to perform simple tasks in R.

How to do it…

The logic for if else statements is very simple and is as follows:

if(x>3){
  print("greater value")
}else {
  print("lesser value")
}

We can copy and paste the preceding statement in the R console or write a function that makes use of the if else logic.

How it works…

The logic behind if else statements is very simple. The following lines clearly state the logic:

if(condition){
#perform some action
}else {
  #perform some other action
}

The preceding code will check whether x is greater than or less than 3, and simply print it. In order to get the value, we type the following in the R command window:

x = 2

Basic loops in R

If we want to perform an action repeatedly in R, we can utilize the loop functionality.

How to do it…

The following lines of code multiply each element of x and y and store them as a vector z:

x = c(1:10)
y = c(1:10)
for(i in 1:10){
z[i] = x[i]*y[i]
}

How it works…

In the preceding code, a calculation is executed 10 times. R performs any calculation specified within {}. We are instructing R to multiply each element of x (using the x[i] notation) by each element in y and store the result in z.

Nested loops in R

We can nest loops, as well as if statements, to perform some more complicated tasks. In this recipe, we will first define a square matrix and then write a nested for loop to print only those values where I = J, namely, the values in the matrix placed in (1,1), (2,2), and so on.

How to do it…

We first define a matrix in R using the following matrix() function:

mat= matrix(1:25, 5,5)

Now, we use the following code to output only those elements where I = J:

for (i in 1:5){
  for (j in 1:5){
    if (i ==j){
      print(mat[i,j])
    }
   }
}

The if statement is nested inside two for loop statements. As we have a matrix, we have to use two for loops instead of just one. The output of the matrix would be values such as 1, 7, 13, and 19.

The apply, lapply, sapply, and tapply functions

R has some very handy functions such as apply, sapply, tapply, and mapply, that can be used to reduce the task of writing complicated statements. Also, using them makes our code look cleaner. The apply() function is similar to writing a loop statement.

The lapply() function is very similar to the apply() function but can be used on lists; this will return a list. The sapply() function is very similar to lapply() but returns a vector and not a list.

How to do it…

The apply() function can be used as follows:

mat= matrix(1:25, 5,5)
apply(mat,1,sd)

The lapply() function can be used in the following way:

j = list(x = 1:4, b = rnorm(100,1,2))
lapply(j,mean)

The tapply() function is useful when we have broken a vector into factors, groups, or categories:

tapply(mtcars$mpg,mtcars$gear,mean)

How it works…

The first argument in the apply() function is the data. The second argument takes two values: 1 and 2; if we state 1, R will perform a row-wise computation; if we mention 2, R will perform a column-wise computation. The third argument is the function. We would like to calculate the standard deviation of each row in R; hence we use the sd function as the third argument. Note that we can define our own function and replace it with the sd function.

With regard to the lapply() function, we have defined J as a list and would like to calculate the mean. The first argument in the lapply() function is the data and the second argument is the function used to process the data.

The first argument in the tapply() function is the data; in our case it is mpg. The second argument is the factor or the grouping; in this case it would be gears. The last argument is the function used to process the data. We would like to calculate the mean of mpg for each unique gear (3, 4, and 5 gears) in the mtcars data.

Using par to beautify a plot in R

One quick and easy way to edit a plot is by generating the plot in R and then using Inkspace or any other software to edit it. We can save some valuable time if we know some basic edits that can be applied on a plot by setting them in a par() function. All the available options to edit a plot can be studied in detail by typing ?par in the command window.

How to do it…

In the following code, I have highlighted some commonly used parameters:

x=c(1:10)
y=c(1:10)
par(bg = "#646989", las = 1, col.lab = "black", col.axis = "white",bty = "n",cex.axis = 0.9,cex.lab= 1.5)
plot(x,y, pch = 20, xlab = "fake x data", ylab = "fake y data")

How it works…

Under the par() function, we have set the background color using the bg = argument. The las = argument changes the orientation of the labels. The col.lab and col.axis arguments are used to specify the color of the labels as well as the axis. The cex argument is used to specify the size of the labels and axis. The bty argument is used to specify the box style in R.

Saving plots

We can save a plot in various formats, such as .jpeg, .svg, .pdf, or .png. I prefer saving a plot as a .png file, as it is easier to edit a plot with Inkspace if saved in the PNG format.

How to do it…

To save a plot in the .png format, we can use the png() function as follows:

png("TEST.png", width = 300, height = 600)
plot(x,y, xlab = "x axis", ylab = "y axis", cex.lab = 3,col.lab = "red", main = "some data", cex.main=1.5, col.main = "red")
dev.off()

How it works…

We have used the png() function to save the plot as a PNG. To save a plot as a PDF, SVG, or JPEG, we can use the pdf(), svg(), or jpeg() functions, respectively.

The first argument in the png() function is the name of the file with the extension, followed by the width and height of the plot. We can now use the plot() function to generate a plot; any subsequent plots will also be saved with a .png extension, unless the dev.off() function is passed. The dev.off() function instructs R that we do not need to save the plots.

Left arrow icon Right arrow icon

Description

If you are a data journalist, academician, student or freelance designer who wants to learn about data visualization, this book is for you. Basic knowledge of R programming is expected.

Who is this book for?

If you are a data journalist, academician, student or freelance designer who wants to learn about data visualization, this book is for you. Basic knowledge of R programming is expected.

What you will learn

  • Generate various plots in R using the basic R plotting techniques
  • Utilize R packages to add context and meaning to your data
  • Design interactive visualizations and integrate them on your website or blog
  • Communicate using visualization techniques, optimal for the underlying data being used as input
  • Create presentations and learn the basics of creating apps in R for your audience
  • Introduce users to basic R functions and data manipulation techniques while creating meaningful visualizations
  • Add elements, text, animation, and colors to your plot to make sense of data
Estimated delivery fee Deliver to Great Britain

Standard delivery 1 - 4 business days

£4.95

Premium delivery 1 - 4 business days

£7.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 29, 2015
Length: 236 pages
Edition : 1st
Language : English
ISBN-13 : 9781783989508
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Great Britain

Standard delivery 1 - 4 business days

£4.95

Premium delivery 1 - 4 business days

£7.95
(Includes tracking information)

Product Details

Publication date : Jan 29, 2015
Length: 236 pages
Edition : 1st
Language : English
ISBN-13 : 9781783989508
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
£16.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
£169.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just £5 each
Feature tick icon Exclusive print discounts
£234.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just £5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total £ 119.97
Machine Learning with R
£41.99
R Data Visualization Cookbook
£35.99
R for Data Science
£41.99
Total £ 119.97 Stars icon
Banner background image

Table of Contents

11 Chapters
1. A Simple Guide to R Chevron down icon Chevron up icon
2. Basic and Interactive Plots Chevron down icon Chevron up icon
3. Heat Maps and Dendrograms Chevron down icon Chevron up icon
4. Maps Chevron down icon Chevron up icon
5. The Pie Chart and Its Alternatives Chevron down icon Chevron up icon
6. Adding the Third Dimension Chevron down icon Chevron up icon
7. Data in Higher Dimensions Chevron down icon Chevron up icon
8. Visualizing Continuous Data Chevron down icon Chevron up icon
9. Visualizing Text and XKCD-style Plots Chevron down icon Chevron up icon
10. Creating Applications in R Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.2
(6 Ratings)
5 star 50%
4 star 33.3%
3 star 0%
2 star 16.7%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




Stephen Davis May 15, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I purchased this book as a companion and additional reference for a class I was taking. As with all the cookbooks I've purchased from Packt Publishing, its a great source for beginners (like myself) to intermediate skills. The first chapter sets the foundation that you need, and then the remainder chapters provides easy to follow walk-through.
Amazon Verified review Amazon
Riadh May 11, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is not about naive plotting topics, this is one of the uncommons that discuss data visualization in R. The book starts with basic knowledge needed to allow a better understanding of the coming developments (Chapter 1). Chapters 2 to 9 treat the main visualization topics from basic to very developed ones (pies, bars, maps, dendrograms, heat maps, text, 3D visualizations, bubbles, timlines, waterfalls, trees, calendars…). The last chapter is an introduction to application development for Dataviz (Google Charts, Shiny…). The cookbook format is very useful and is full of tips that everyone can adapt to their needs. Differences between simple charts and data visualization tasks are very subtle and this book will help you moving forward to the next stage. In addition to specific packages, the author have a gift for making professional visualizations using the basic charting capabilities of R (you can see an example in the author’s blog here datavisualizationineconomics.blogspot.com/2015/01/oil-prices-and-its-relationship-with.html). If you want to acquire the artistic taste necessary to develop your dataviz skills, this book is definitely for you!I’m sorry for my elementary English, I’m not native speaker, and fortunately I read better than I write! :)
Amazon Verified review Amazon
AS Apr 27, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I would recommend this as an introductory level book for R. I come from a python background but needed to catch up on R pretty quickly for a course that I was taking from school. The book came in handy mainly for the code that comes with the chapters affiliated with the examples. There are some good sample data examples that can leverage the power of R especially with importing csv files into it and showing the advantages that can come to using R over other tools like Excel for visualizazing data.
Amazon Verified review Amazon
Barry Higgins May 01, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
A very well laid out book, with some excellent examples to get you up an running with building visualizations using R. I really like the approach taken by the author were you quickly build a plot or graph using the downloadable data sets. Then you are provided with a detailed explanation of the code used to generate the graphic. Each chapter deals with a specific visualization type and gives plenty of examples of what can be achieved with each one. The author also explains why particular plots are suitable for a particular data type, i.e. One plot does not fit all.
Amazon Verified review Amazon
PJG Apr 23, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This is an interesting book.Firstly, I'll clarify what the book does NOT include: ggplot2 is mentioned in a couple of places but, as the author points out, there are plenty of resources available to learn the package and so only a few of the recipes in there use ggplot2. The ggvis package is not touched upon at all.Where the book is interesting, and it's strength, is showing the breadth and depth of data visualization that is possible in R - often from pretty obscure packages! One of the recipes use the XKCD package to show visualizations reminiscent of the well-know web comic, which is a nice use for R to liven up some bland presentations. Similarly, animated plots in R, various types of wordclouds and phrase trees, 'violin' plots and network plots are all covered. It's nice to see so many things touched upon.If you use R for data analysis and are looking for novel, fresh and aesthetically-appealing ways to present your data, this book comes highly recommended.It's useful to be able to skim through the book and find examples of graphics of interest and then follow the details (which are clear and generally pretty well explained). If you want a detailed guide to ggplot2, as the author suggests there are other resources that will meet your need.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela