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
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Twitter text


We will leverage the twitteR package to extract tweets. Refer to https://cran.r-project.org/web/packages/twitteR/index.html to get more information about this package.

In order to use this package, you need a Twitter account. With the account, sign in to https://app.twitter.com and create an application. Use the consumer key, consumer secret key, access token, and access token security keys from that page to authenticate into Twitter.

Authorizing with keys into Twitter is done as follows:

library(twitteR, quietly = TRUE)
setup_twitter_oauth(consumer.key, consumer.secret, access.token, token.secret)

We are ready to extract some tweets.

We will retrieve only the English tweets using the searchTwitter function provided by the twitteR package:

tweet.results <- searchTwitter("@apple", n=1000,lang = "en")
tweet.df <- twListToDF(tweet.results)

Using the function twListToDF, we convert our extracted tweets from Twitter to a dataframe, tweet.df. Out of all the fields extracted, we are...