Synopses & Reviews
Learn how to perform data analysis with the R language and software environment, even if you have little or no programming experience. With the tutorials in this hands-on guide, youll learn how to use the essential R tools you need to know to analyze data, including data types and programming concepts.
The second half of Learning R shows you real data analysis in action by covering everything from importing data to publishing your results. Each chapter in the book includes a quiz on what youve learned, and concludes with exercises, most of which involve writing R code.
- Write a simple R program, and discover what the language can do
- Use data types such as vectors, arrays, lists, data frames, and strings
- Execute code conditionally or repeatedly with branches and loops
- Apply R add-on packages, and package your own work for others
- Learn how to clean data you import from a variety of sources
- Understand data through visualization and summary statistics
- Use statistical models to pass quantitative judgments about data and make predictions
- Learn what to do when things go wrong while writing data analysis code
If you have basic programming skills and do any kind of data analysis, you need R in your toolkit. This book teaches you how to be productive with this important programming language for statistics by covering everything about R you need to know, including:
- Data gathering from different sources such as web scraping and databases
- Data transformation/manipulation that can save you hours
- Visualization that provides a great way of showing insights into datasets
- Modelling that shows just how many different analyses can be done in R
About the Author
Richie is a data scientist with a background in chemical health and safety, and has worked extensively on tools to give non-technical users access to statistical models. He is the author of the R packages "assertive" for checking the state of your variables and "sig" to make sure your functions have a sensible API. He runs The Damned Liars statistics consultancy.
Table of Contents
Preface; About This Book; What Is in This Book; Which Chapters Should I Read?; Conventions Used in This Book; Goals, Summaries, Quizzes, and Exercises; Using Code Examples; Safari® Books Online; How to Contact Us; Acknowledgments; The R Language; Chapter 1: Introduction; 1.1 Chapter Goals; 1.2 What Is R?; 1.3 Installing R; 1.4 Choosing an IDE; 1.5 Your First Program; 1.6 How to Get Help in R; 1.7 Installing Extra Related Software; 1.8 Summary; 1.9 Test Your Knowledge: Quiz; 1.10 Test Your Knowledge: Exercises; Chapter 2: A Scientific Calculator; 2.1 Chapter Goals; 2.2 Mathematical Operations and Vectors; 2.3 Assigning Variables; 2.4 Special Numbers; 2.5 Logical Vectors; 2.6 Summary; 2.7 Test Your Knowledge: Quiz; 2.8 Test Your Knowledge: Exercises; Chapter 3: Inspecting Variables and Your Workspace; 3.1 Chapter Goals; 3.2 Classes; 3.3 Different Types of Numbers; 3.4 Other Common Classes; 3.5 Checking and Changing Classes; 3.6 Examining Variables; 3.7 The Workspace; 3.8 Summary; 3.9 Test Your Knowledge: Quiz; 3.10 Test Your Knowledge: Exercises; Chapter 4: Vectors, Matrices, and Arrays; 4.1 Chapter Goals; 4.2 Vectors; 4.3 Matrices and Arrays; 4.4 Summary; 4.5 Test Your Knowledge: Quiz; 4.6 Test Your Knowledge: Exercises; Chapter 5: Lists and Data Frames; 5.1 Chapter Goals; 5.2 Lists; 5.3 NULL; 5.4 Pairlists; 5.5 Data Frames; 5.6 Summary; 5.7 Test Your Knowledge: Quiz; 5.8 Test Your Knowledge: Exercises; Chapter 6: Environments and Functions; 6.1 Chapter Goals; 6.2 Environments; 6.3 Functions; 6.4 Summary; 6.5 Test Your Knowledge: Quiz; 6.6 Test Your Knowledge: Exercises; Chapter 7: Strings and Factors; 7.1 Chapter Goals; 7.2 Strings; 7.3 Factors; 7.4 Summary; 7.5 Test Your Knowledge: Quiz; 7.6 Test Your Knowledge: Exercises; Chapter 8: Flow Control and Loops; 8.1 Chapter Goals; 8.2 Flow Control; 8.3 Loops; 8.4 Summary; 8.5 Test Your Knowledge: Quiz; 8.6 Test Your Knowledge: Exercises; Chapter 9: Advanced Looping; 9.1 Chapter Goals; 9.2 Replication; 9.3 Looping Over Lists; 9.4 Looping Over Arrays; 9.5 Multiple-Input Apply; 9.6 Split-Apply-Combine; 9.7 The plyr Package; 9.8 Summary; 9.9 Test Your Knowledge: Quiz; 9.10 Test Your Knowledge: Exercises; Chapter 10: Packages; 10.1 Chapter Goals; 10.2 Loading Packages; 10.3 Installing Packages; 10.4 Maintaining Packages; 10.5 Summary; 10.6 Test Your Knowledge: Quiz; 10.7 Test Your Knowledge: Exercises; Chapter 11: Dates and Times; 11.1 Chapter Goals; 11.2 Date and Time Classes; 11.3 Conversion to and from Strings; 11.4 Time Zones; 11.5 Arithmetic with Dates and Times; 11.6 Lubridate; 11.7 Summary; 11.8 Test Your Knowledge: Quiz; 11.9 Test Your Knowledge: Exercises; The Data Analysis Workflow; Chapter 12: Getting Data; 12.1 Chapter Goals; 12.2 Built-in Datasets; 12.3 Reading Text Files; 12.4 Reading Binary Files; 12.5 Web Data; 12.6 Accessing Databases; 12.7 Summary; 12.8 Test Your Knowledge: Quiz; 12.9 Test Your Knowledge: Exercises; Chapter 13: Cleaning and Transforming; 13.1 Chapter Goals; 13.2 Cleaning Strings; 13.3 Manipulating Data Frames; 13.4 Sorting; 13.5 Functional Programming; 13.6 Summary; 13.7 Test Your Knowledge: Quiz; 13.8 Test Your Knowledge: Exercises; Chapter 14: Exploring and Visualizing; 14.1 Chapter Goals; 14.2 Summary Statistics; 14.3 The Three Plotting Systems; 14.4 Scatterplots; 14.5 Line Plots; 14.6 Histograms; 14.7 Box Plots; 14.8 Bar Charts; 14.9 Other Plotting Packages and Systems; 14.10 Summary; 14.11 Test Your Knowledge: Quiz; 14.12 Test Your Knowledge: Exercises; Chapter 15: Distributions and Modeling; 15.1 Chapter Goals; 15.2 Random Numbers; 15.3 Distributions; 15.4 Formulae; 15.5 A First Model: Linear Regressions; 15.6 Other Model Types; 15.7 Summary; 15.8 Test Your Knowledge: Quiz; 15.9 Test Your Knowledge: Exercises; Chapter 16: Programming; 16.1 Chapter Goals; 16.2 Messages, Warnings, and Errors; 16.3 Error Handling; 16.4 Debugging; 16.5 Testing; 16.6 Magic; 16.7 Object-Oriented Programming; 16.8 Summary; 16.9 Test Your Knowledge: Quiz; 16.10 Test Your Knowledge: Exercises; Chapter 17: Making Packages; 17.1 Chapter Goals; 17.2 Why Create Packages?; 17.3 Prerequisites; 17.4 The Package Directory Structure; 17.5 Your First Package; 17.6 Documenting Packages; 17.7 Checking and Building Packages; 17.8 Maintaining Packages; 17.9 Summary; 17.10 Test Your Knowledge: Quiz; 17.11 Test Your Knowledge: Exercises; Appendixes; Properties of Variables; Other Things to Do in R; Answers to Quizzes; Solutions to Exercises; Bibliography; Index; Colophon;