Book Image

R Data Analysis Projects

Book Image

R Data Analysis Projects

Overview of this book

R offers a large variety of packages and libraries for fast and accurate data analysis and visualization. As a result, it’s one of the most popularly used languages by data scientists and analysts, or anyone who wants to perform data analysis. This book will demonstrate how you can put to use your existing knowledge of data analysis in R to build highly efficient, end-to-end data analysis pipelines without any hassle. You’ll start by building a content-based recommendation system, followed by building a project on sentiment analysis with tweets. You’ll implement time-series modeling for anomaly detection, and understand cluster analysis of streaming data. You’ll work through projects on performing efficient market data research, building recommendation systems, and analyzing networks accurately, all provided with easy to follow codes. With the help of these real-world projects, you’ll get a better understanding of the challenges faced when building data analysis pipelines, and see how you can overcome them without compromising on the efficiency or accuracy of your systems. The book covers some popularly used R packages such as dplyr, ggplot2, RShiny, and others, and includes tips on using them effectively. By the end of this book, you’ll have a better understanding of data analysis with R, and be able to put your knowledge to practical use without any hassle.
Table of Contents (15 chapters)
Title Page
About the Author
About the Reviewer
Customer Feedback

Graphs in R

We will use the R package, igraph, for our graph analysis needs. We will leverage the arules package to manipulate our data. If you don't have them installed, proceed to install them as follows:

>  install.packages("arules")
>  install.packages("igraph")

You can use the sessionInfo function from the utils package to look at the packages available for you in the current session.

Let's get started; create a simple graph, and plot it:

> library(igraph, quietly = TRUE)
> simple.graph <- graph_from_literal(A-B, B-C, C-D, E-F, A-E, E-C)
> plot.igraph(simple.graph)

This produces the following graph plot:

After including the igraph library, we used the graph_from_literal function to create a simple undirected graph with six nodes. The igraph package provides the plot.igraph function to visualize the graphs. There are several ways in which we can create a graph. For a complete list of the different methods available to create graphs, refer to