Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
R Data Visualization Recipes

You're reading from   R Data Visualization Recipes A cookbook with 65+ data visualization recipes for smarter decision-making

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788398312
Length 366 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
 Bianchi Lanzetta Bianchi Lanzetta
Author Profile Icon Bianchi Lanzetta
Bianchi Lanzetta
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Title Page
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
1. Installation and Introduction FREE CHAPTER 2. Plotting Two Continuous Variables 3. Plotting a Discrete Predictor and a Continuous Response 4. Plotting One Variable 5. Making Other Bivariate Plots 6. Creating Maps 7. Faceting 8. Designing Three-Dimensional Plots 9. Using Theming Packages 10. Designing More Specialized Plots 11. Making Interactive Plots 12. Building Shiny Dashboards

Preface

Visualizations are amazing to investigate. You can explore data, reach insights, and transmit them directly to your audience. When several paragraphs may be needed to prove a point, good figures do it better in just a glance; they literally do. Fortunately, as computers keep evolving, crafting first-class graphs is not that difficult anymore.

R has proven itself an amazing tool for both data analysis and visualization. It all began by as an open source, well-designed, and multi-propose programming language that did not require much programming background to use. So, as R rose in popularity, a vivid and helpful community has also arisen.

The community itself has done much to keep improving the language. They have designed and shared tons of packages, which brings us to here and now. This book is full of examples on how to easily brew pretty graphics using very popular packages. It aims for teaching the nuts and bolts related to many different visuals, along with very useful tricks to adapt and enhance your figures.

Examples range from static scatterplots built using ggplot2 to interactive globes formed by plotly. Learn how to plot the most tweeted words by some user, draw true 3D interactive surfaces, and build shiny dashboards. Also you will learn how to apply a theme that will support your analysis.

What this book covers

Chapter 1, Installation and Introduction, teaches how to install the three most popular R visualization packages: ggplot2, ggvis, and plotly. This chapter introduces the ways a package can be installed: either from a CRAN repository or a GitHub one. You also get to know how to call functions from those packages while going through some examples demonstrating the basic framework of those packages.

Chapter 2, Plotting Two Continuous Variables, dives into scatterplots, the most popular way to plot two continuous variables. We learn how to change shapes, colors and sizes. The main problem imbued to scatterplots is called over plotting; this chapter explores related solutions. Also we see how to draw marginal plots and produce high-quality scatterplots.

Chapter 3, Plotting a Discrete Predictor and a Continuous Response, covers distributions over categories, a great way to explore your data. It can be handled using R to draw one box plots, bivariate dot plots, and violin plots. Learn how to draw and combine each of them. Meet nice additional features while learning the art of crafting to publish quality violin plots.

Chapter 4, Plotting One Variable, covers histograms, density plots, area plots, univariate dot plots, and univariate bar graphs. Learn how to brew these visuals under different R packages. Meet the useful modifications achieved by little code tweaks.

Chapter 5, Making Other Bivariate Plots. Trust this chapter to build bars of all kinds, line graphs, hexagon plots, and deploy variability estimates (error bars). Bars can be displayed as stacked, proportional, and/or side by side. Despite the wide variability of bars available, there are also some useful tricks to learn.

Chapter 6, Creating Maps, Demonstrating spatial correlation is mustily done through maps. Learn how points, lines, and polygons can be used to craft maps through R packages. Meet the John Snow cholera map, Tolkien's Middle Earth map, and an interactive globe of banking crisis. Also learn how to read shapefiles from temporary directories and how projection types can be coerced.

Chapter 7, Faceting, covers an important device that allows comprehension on more complex data relations. Recipes within this chapter teach how different kinds of visuals can easily reach out for faceting using ggplot2. Additionally, this chapter teaches how those can be coerced into interactive visuals by relying on the plotly package.

Chapter 8, Designing Three-Dimensional Plots. Although ggplot2 is not capable of drawing true 3D surfaces, it can draw their 2D representations. This chapter demonstrates the craft of contour, tile, and raster plots using ggplot2. It also demonstrates how to draw true and interactive 3D surfaces using plotly.

Chapter 9, Using Theming Packages, teaches how several themming packages can be used to coerce several themes to a ggplot. These range from themes inspired by The Simpsons and Star Trek to respectful academic journal themes. Also learn how to wrap a theme of your own into a function.

Chapter 10, Designing More Specialized Plots. Meet the complementary ggplot2 packages: ggforce, ggrepel, ggraph, and ggalt. These can be used to simple tasks like zooming in to more complex tasks like avoiding labels and texts inside the graph to overlay each other.

Chapter 11, Making Interactive Plots, explains how the ggiraphgganimate, and tweenr packages can be used to create ggplot2 based animations and design interactive features. Animations are an useful way to denote how data variables have evolved with wonderful applications to all kinds of visuals.

Chapter 12, Building Shiny Dashboards. shiny allows the user to make interactive web applications direct from R. The package shinydashboard makes easier to create dash boards using shiny. This recipe demonstrates how to construct those while customizing styles, side bars, and more.

What you need for this book

First things first, download the latest version of R (https://cran.r-project.org/). Additionally, recipes were written using a IDE named RStudio (free version). I do prefer to write R codes under RStudio IDE; if you do not have the software yet, you can get it from https://www.rstudio.com/products/rstudio/download/.

Who this book is for

If you are looking to create custom data visualization solutions using the R programming language and are stuck somewhere in the process, this book will come to your rescue. Prior exposure to packages such as ggplot2 will be useful but not necessary. Some programming knowledge of R is required for this book.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning. Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "This chapter covers basic aspects of three of them: ggplot2,plotly, and ggvis."

A block of code is set as follows:

> install.packages(c('devtools','plotly','ggvis'))
> devtools::install_github('hadley/ggplot2')

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Open your RStudio, go to Tools|Install Packages..."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply email [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book 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 emailed directly to you. You can download the code files by following these steps:

  1. Log in or register to our website using your email address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.

 

  1. Enter the name of the book in the Search box.
  2. Select the book for which you're looking to download the code files.
  3. Choose from the drop-down menu where you purchased this book from.
  4. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/R-Data-Visualization-Recipes. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

 

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title. To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at [email protected] with a link to the suspected pirated material. We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images