| |
| |
Acknowledgments | |
| |
| |
Introduction | |
| |
| |
Why Use R for Your Statistical Work? | |
| |
| |
Whom Is This Book For? | |
| |
| |
My Own Background | |
| |
| |
| |
Getting Started | |
| |
| |
| |
How to Run R | |
| |
| |
| |
A First R Session | |
| |
| |
| |
Introduction to Functions | |
| |
| |
| |
Preview of Some Important R Data Structures | |
| |
| |
| |
Extended Example: Regression Analysis of Exam Grades | |
| |
| |
| |
Startup and Shutdown | |
| |
| |
| |
Getting Help | |
| |
| |
| |
Vectors | |
| |
| |
| |
Scalars, Vectors, Arrays, and Matrices | |
| |
| |
| |
Declarations | |
| |
| |
| |
Recycling | |
| |
| |
| |
Common Vector Operations | |
| |
| |
| |
Using all() and any() | |
| |
| |
| |
Vectorized Operations | |
| |
| |
| |
NA and NULL Values | |
| |
| |
| |
Filtering | |
| |
| |
| |
A Vectorized if-then-else: The ifelse() Function | |
| |
| |
| |
Testing Vector Equality | |
| |
| |
| |
Vector Element Names | |
| |
| |
| |
More on c() | |
| |
| |
| |
Matrices and Arrays | |
| |
| |
| |
Creating Matrices | |
| |
| |
| |
General Matrix Operations | |
| |
| |
| |
Applying Functions to Matrix Rows and Columns | |
| |
| |
| |
Adding and Deleting Matrix Rows and Columns | |
| |
| |
| |
More on the Vector/Matrix Distinction | |
| |
| |
| |
Avoiding Unintended Dimension Reduction | |
| |
| |
| |
Naming Matrix Rows and Columns | |
| |
| |
| |
Higher-Dimensional Arrays | |
| |
| |
| |
Lists | |
| |
| |
| |
Creating Lists | |
| |
| |
| |
General List Operations | |
| |
| |
| |
Accessing List Components and Values | |
| |
| |
| |
Applying Functions to Lists | |
| |
| |
| |
Recursive Lists | |
| |
| |
| |
Data Frames | |
| |
| |
| |
Creating Data Frames | |
| |
| |
| |
Other Matrix-Like Operations | |
| |
| |
| |
Merging Data Frames | |
| |
| |
| |
Applying Functions to Data Frames | |
| |
| |
| |
Factors and Tables | |
| |
| |
| |
Factors and Levels | |
| |
| |
| |
Common Functions Used with Factors | |
| |
| |
| |
Working with Tables | |
| |
| |
| |
Other Factor- and Table-Related Functions | |
| |
| |
| |
R Programming Structures | |
| |
| |
| |
Control Statements | |
| |
| |
| |
Arithmetic and Boolean Operators and Values | |
| |
| |
| |
Default Values for Arguments | |
| |
| |
| |
Return Values | |
| |
| |
| |
Functions Are Objects | |
| |
| |
| |
Environment and Scope Issues | |
| |
| |
| |
No Pointers in R | |
| |
| |
| |
Writing Upstairs | |
| |
| |
| |
Recursion | |
| |
| |
| |
Replacement Functions | |
| |
| |
| |
Tools for Composing Function Code | |
| |
| |
| |
Writing Your Own Binary Operations | |
| |
| |
| |
Anonymous Functions | |
| |
| |
| |
Doing Math and Simulations in R | |
| |
| |
| |
Math Functions | |
| |
| |
| |
Functions for Statistical Distributions | |
| |
| |
| |
Sorting | |
| |
| |
| |
Linear Algebra Operations on Vectors and Matrices | |
| |
| |
| |
Set Operations | |
| |
| |
| |
Simulation Programming in R | |
| |
| |
| |
Object-Oriented Programming | |
| |
| |
| |
S3 Classes | |
| |
| |
| |
S4 Classes | |
| |
| |
| |
S3 Versus S4 | |
| |
| |
| |
Managing Your Objects | |
| |
| |
| |
Input/Output | |
| |
| |
| |
Accessing the Keyboard and Monitor | |
| |
| |
| |
Reading and Writing Files | |
| |
| |
| |
Accessing the Internet | |
| |
| |
| |
String Manipulation | |
| |
| |
| |
An Overview of String-Manipulation Functions | |
| |
| |
| |
Regular Expressions | |
| |
| |
| |
Use of String Utilities in the edtdbg Debugging Tool | |
| |
| |
| |
Graphics | |
| |
| |
| |
Creating Graphs | |
| |
| |
| |
Customizing Graphs | |
| |
| |
| |
Saving Graphs to Files | |
| |
| |
| |
Creating Three-Dimensional Plots | |
| |
| |
| |
Debugging | |
| |
| |
| |
Fundamental Principles of Debugging | |
| |
| |
| |
Why Use a Debugging Tool? | |
| |
| |
| |
Using R Debugging Facilities | |
| |
| |
| |
Moving Up in the World: More Convenient Debugging Tools | |
| |
| |
| |
Ensuring Consistency in Debugging Simulation Code | |
| |
| |
| |
Syntax and Runtime Errors | |
| |
| |
| |
Running GDB on R Itself | |
| |
| |
| |
Performance Enhancement: Speed and Memory | |
| |
| |
| |
Writing Fast R Code | |
| |
| |
| |
The Dreaded for Loop | |
| |
| |
| |
Functional Programming and Memory Issues | |
| |
| |
| |
Using Rprof() to Find Slow Spots in Your Code | |
| |
| |
| |
Byte Code Compilation | |
| |
| |
| |
Oh No, the Data Doesn't Fit into Memory! | |
| |
| |
| |
Interfacing R to Other Languages | |
| |
| |
| |
Writing C/C++ Functions to Be Called from R | |
| |
| |
| |
Using R from Python | |
| |
| |
| |
Parallel R | |
| |
| |
| |
The Mutual Outlinks Problem | |
| |
| |
| |
Introducing the snow Package | |
| |
| |
| |
Resorting to C | |
| |
| |
| |
General Performance Considerations | |
| |
| |
| |
Debugging Parallel R Code; Installing R | |
| |
| |
Downloading R from CRAN | |
| |
| |
Installing from a Linux Package Manager | |
| |
| |
Installing from Source; Installing and Using Packages | |
| |
| |
Package Basics | |
| |
| |
Loading a Package from Your Hard Drive | |
| |
| |
Downloading a Package from the Web | |
| |
| |
Listing the Functions in a Package | |
| |
| |
Colophon | |