Book Image

Hands-On Data Science with R

By : Vitor Bianchi Lanzetta, Doug Ortiz, Nataraj Dasgupta, Ricardo Anjoleto Farias
Book Image

Hands-On Data Science with R

By: Vitor Bianchi Lanzetta, Doug Ortiz, Nataraj Dasgupta, Ricardo Anjoleto Farias

Overview of this book

R is the most widely used programming language, and when used in association with data science, this powerful combination will solve the complexities involved with unstructured datasets in the real world. This book covers the entire data science ecosystem for aspiring data scientists, right from zero to a level where you are confident enough to get hands-on with real-world data science problems. The book starts with an introduction to data science and introduces readers to popular R libraries for executing data science routine tasks. This book covers all the important processes in data science such as data gathering, cleaning data, and then uncovering patterns from it. You will explore algorithms such as machine learning algorithms, predictive analytical models, and finally deep learning algorithms. You will learn to run the most powerful visualization packages available in R so as to ensure that you can easily derive insights from your data. Towards the end, you will also learn how to integrate R with Spark and Hadoop and perform large-scale data analytics without much complexity.
Table of Contents (16 chapters)

Cleaning and transforming data

In Chapter 3, Data Wrangling with R, we approached the topic of data cleaning (munging). Data cleaning is so important that the majority of data scientists spend most of their work time cleaning and preparing data. The last session, What is the R community tweeting about?, gave us a DataFrame with 15999 rows and 42 columns. That is raw data. This session will clean and transform it.

Our initial goal was to check which packages the R community is talking about on Twitter. There are three variables we will use to achieve the final goal.

The variable text can be truncated when there is a retweet. When that is the case, check retweet_text, which won't be truncated. The quoted_text variable also brings useful information. To unite all the useful information into a single object, we can use the following code:

quotes <- tweets_dt$is_quote
rts...