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

No credit card required

## Book Description

R is the world's most popular language for developing statistical software: Archaeologists use it to track the spread of ancient civilizations, drug companies use it to discover which medications are safe and effective, and actuaries use it to assess financial risks and keep economies running smoothly.

1. Art of R Programming
1. Acknowledgments
2. Introduction
1. Why Use R for Your Statistical Work?
2. Whom Is This Book For?
3. My Own Background
3. 1. Getting Started
1. How to Run R
2. A First R Session
3. Introduction to Functions
4. Preview of Some Important R Data Structures
1. Vectors, the R Workhorse
2. Character Strings
3. Matrices
4. Lists
5. Data Frames
6. Classes
5. Extended Example: Regression Analysis of Exam Grades
6. Startup and Shutdown
7. Getting Help
4. 2. Vectors
1. Scalars, Vectors, Arrays, and Matrices
2. Declarations
3. Recycling
4. Common Vector Operations
5. Using all() and any()
6. Vectorized Operations
7. NA and NULL Values
8. Filtering
9. A Vectorized if-then-else: The ifelse() Function
10. Testing Vector Equality
11. Vector Element Names
12. More on c()
5. 3. Matrices and Arrays
1. Creating Matrices
2. General Matrix Operations
3. Applying Functions to Matrix Rows and Columns
4. Adding and Deleting Matrix Rows and Columns
5. More on the Vector/Matrix Distinction
6. Avoiding Unintended Dimension Reduction
7. Naming Matrix Rows and Columns
8. Higher-Dimensional Arrays
6. 4. Lists
1. Creating Lists
2. General List Operations
3. Accessing List Components and Values
4. Applying Functions to Lists
5. Recursive Lists
7. 5. Data Frames
1. Creating Data Frames
2. Other Matrix-Like Operations
3. Merging Data Frames
4. Applying Functions to Data Frames
8. 6. Factors and Tables
1. Factors and Levels
2. Common Functions Used with Factors
3. Working with Tables
4. Other Factor- and Table-Related Functions
9. 7. R Programming Structures
1. Control Statements
2. Arithmetic and Boolean Operators and Values
3. Default Values for Arguments
4. Return Values
5. Functions Are Objects
6. Environment and Scope Issues
7. No Pointers in R
8. Writing Upstairs
9. Recursion
10. Replacement Functions
11. Tools for Composing Function Code
12. Writing Your Own Binary Operations
13. Anonymous Functions
10. 8. Doing Math and Simulations in R
1. Math Functions
2. Functions for Statistical Distributions
3. Sorting
4. Linear Algebra Operations on Vectors and Matrices
5. Set Operations
6. Simulation Programming in R
11. 9. Object-Oriented Programming
1. S3 Classes
2. S4 Classes
3. S3 Versus S4
12. 10. Input/Output
1. Accessing the Keyboard and Monitor
3. Accessing the Internet
13. 11. String Manipulation
1. An Overview of String-Manipulation Functions
2. Regular Expressions
3. Use of String Utilities in the edtdbg Debugging Tool
14. 12. Graphics
1. Creating Graphs
2. Customizing Graphs
3. Saving Graphs to Files
4. Creating Three-Dimensional Plots
15. 13. Debugging
1. Fundamental Principles of Debugging
2. Why Use a Debugging Tool?
3. Using R Debugging Facilities
1. Single-Stepping with the debug() and browser() Functions
2. Using Browser Commands
3. Setting Breakpoints
4. Tracking with the trace() Function
5. Performing Checks After a Crash with the traceback() and debugger() Function
6. Extended Example: Two Full Debugging Sessions
4. Moving Up in the World: More Convenient Debugging Tools
5. Ensuring Consistency in Debugging Simulation Code
6. Syntax and Runtime Errors
7. Running GDB on R Itself
16. 14. Performance Enhancement: Speed and Memory
1. Writing Fast R Code
3. Functional Programming and Memory Issues
4. Using Rprof() to Find Slow Spots in Your Code
5. Byte Code Compilation
6. Oh No, the Data Doesn’t Fit into Memory!
17. 15. Interfacing R to Other Languages
1. Writing C/C++ Functions to Be Called from R
2. Using R from Python
18. 16. Parallel R