Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Practical Predictive Analytics

You're reading from  Practical Predictive Analytics

Product type Book
Published in Jun 2017
Publisher Packt
ISBN-13 9781785886188
Pages 576 pages
Edition 1st Edition
Languages
Author (1):
Ralph Winters Ralph Winters
Profile icon Ralph Winters

Table of Contents (19) Chapters

Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
Getting Started with Predictive Analytics The Modeling Process Inputting and Exploring Data Introduction to Regression Algorithms Introduction to Decision Trees, Clustering, and SVM Using Survival Analysis to Predict and Analyze Customer Churn Using Market Basket Analysis as a Recommender Engine Exploring Health Care Enrollment Data as a Time Series Introduction to Spark Using R Exploring Large Datasets Using Spark Spark Machine Learning - Regression and Cluster Models Spark Models – Rule-Based Learning

Subsetting the columns


For this exercise, we will be using a restricted set of columns from the CSV file. We can either select the specific columns from the dataframe just read in (if we just read in the whole file), or reread the csv file using the colClasses parameter to only read the columns that are required. Often, this method is preferable when you are reading a large file, and will instruct read.csv to only retain the first three and the last two columns, and ignore the columns priemp through govmilitary.

After rereading in the file, with a subset of the columns, we print a few records from the beginning and end of the file. We can do this using a combination of the rbind(), head(), and tail() functions. This will give us all of the columns we will be using for this chapter, except for some columns, which we will derive in the next section:

x <- read.csv("hihist2bedit.csv", colClasses = c(NA,NA, NA, NA, rep("NULL", 7)))

 rbind(head(x), tail(x)) 
>          Year Year.1 Total.People...
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 $15.99/month. Cancel anytime}