O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Data Scientist's Guide to Acquiring, Cleaning, and Managing Data in R

Book Description

The only how-to guide offering a unified, systemic approach to acquiring, cleaning, and managing data in R

Every experienced practitioner knows that preparing data for modeling is a painstaking, time-consuming process. Adding to the difficulty is that most modelers learn the steps involved in cleaning and managing data piecemeal, often on the fly, or they develop their own ad hoc methods. This book helps simplify their task by providing a unified, systematic approach to acquiring, modeling, manipulating, cleaning, and maintaining data in R. 

Starting with the very basics, data scientists Samuel E. Buttrey and Lyn R. Whitaker walk readers through the entire process. From what data looks like and what it should look like, they progress through all the steps involved in getting data ready for modeling.  They describe best practices for acquiring data from numerous sources; explore key issues in data handling, including text/regular expressions, big data, parallel processing, merging, matching, and checking for duplicates; and outline highly efficient and reliable techniques for documenting data and recordkeeping, including audit trails, getting data back out of R, and more.

  • The only single-source guide to R data and its preparation, it describes best practices for acquiring, manipulating, cleaning, and maintaining data
  • Begins with the basics and walks readers through all the steps necessary to get data ready for the modeling process
  • Provides expert guidance on how to document the processes described so that they are reproducible
  • Written by seasoned professionals, it provides both introductory and advanced techniques
  • Features case studies with supporting data and R code, hosted on a companion website

A Data Scientist's Guide to Acquiring, Cleaning and Managing Data in R is a valuable working resource/bench manual for practitioners who collect and analyze data, lab scientists and research associates of all levels of experience, and graduate-level data mining students.

Table of Contents

  1. Cover
  2. Title Page
  3. Copyright
  4. Dedication
  5. About the Authors
  6. Preface
  7. Acknowledgments
  8. About the Companion Website
  9. chapter 1: R
    1. 1.1 Introduction
    2. 1.2 Data
    3. 1.3 The Very Basics of R
    4. 1.4 Running an R Session
    5. 1.5 Getting Help
    6. 1.6 How to Use This Book
  10. Chapter 2: R Data, Part 1: Vectors
    1. 2.1 Vectors
    2. 2.2 Data Types
    3. 2.3 Subsets of Vectors
    4. 2.4 Missing Data (NA) and Other Special Values
    5. 2.5 The table() Function
    6. 2.6 Other Actions on Vectors
    7. 2.7 Long Vectors and Big Data
    8. 2.8 Chapter Summary and Critical Data Handling Tools
  11. Chapter 3: R Data, Part 2: More Complicated Structures
    1. 3.1 Introduction
    2. 3.2 Matrices
    3. 3.3 Lists
    4. 3.4 Data Frames
    5. 3.5 Operating on Lists and Data Frames
    6. 3.6 Date and Time Objects
    7. 3.7 Other Actions on Data Frames
    8. 3.8 Handling Big Data
    9. 3.9 Chapter Summary and Critical Data Handling Tools
  12. chapter 4: R Data, Part 3: Text and Factors
    1. 4.1 Character Data
    2. 4.2 Converting Numbers into Text
    3. 4.3 Constructing Character Strings: Paste in Action
    4. 4.4 Regular Expressions
    5. 4.5 UTF-8 and Other Non-ASCII Characters
    6. 4.6 Factors
    7. 4.7 R Object Names and Commands as Text
    8. 4.8 Chapter Summary and Critical Data Handling Tools
  13. Chapter 5: Writing Functions and Scripts
    1. 5.1 Functions
    2. 5.2 Scripts and Shell Scripts
    3. 5.3 Error Handling and Debugging
    4. 5.4 Interacting with the Operating System
    5. 5.5 Speeding Things Up
    6. 5.6 Chapter Summary and Critical Data Handling Tools
  14. Chapter 6: Getting Data into and out of R
    1. 6.1 Reading Tabular ASCII Data into Data Frames
    2. 6.2 Reading Large, Non-Tabular, or Non-ASCII Data
    3. 6.3 Reading Data From Relational Databases
    4. 6.4 Handling Large Numbers of Input Files
    5. 6.5 Other Formats
    6. 6.6 Reading and Writing R Data Directly
    7. 6.7 Chapter Summary and Critical Data Handling Tools
  15. Chapter 7: Data Handling in Practice
    1. 7.1 Acquiring and Reading Data
    2. 7.2 Cleaning Data
    3. 7.3 Combining Data
    4. 7.4 Transactional Data
    5. 7.5 Preparing Data
    6. 7.6 Documentation and Reproducibility
    7. 7.7 The Role of Judgment
    8. 7.8 Data Cleaning in Action
    9. 7.9 Chapter Summary and Critical Data Handling Tools
  16. Chapter 8: Extended Exercise
    1. 8.1 Introduction to the Problem
    2. 8.2 The Data
    3. 8.3 Five Important Fields
    4. 8.4 Loan and Application Portfolios
    5. 8.5 Scores
    6. 8.6 Co-borrower Scores
    7. 8.7 Updated KScores
    8. 8.8 Loans to Be Excluded
    9. 8.9 Response Variable
    10. 8.10 Assembling the Final Data Sets
  17. Appendix A: Hints and Pseudocode
    1. A.1 Loan Portfolios
    2. A.2 Scores Database
    3. A.3 Co-borrower Scores
    4. A.4 Updated KScores
    5. A.5 Excluder Files
    6. A.6 Payment Matrix
    7. A.7 Starting the Modeling Process
  18. Bibliography
  19. Index
  20. End User License Agreement