HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
Statistical Computation for Programmers, Scientists, Quants, Excel Users, and Other Professionals
Using the open source R language, you can build powerful statistical models to answer many of your most challenging questions. R has traditionally been difficult for non-statisticians to learn, and most R books assume far too much knowledge to be of help. R for Everyone is the solution.
Drawing on his unsurpassed experience teaching new users, professional data scientist Jared P. Lander has written the perfect tutorial for anyone new to statistical programming and modeling. Organized to make learning easy and intuitive, this guide focuses on the 20 percent of R functionality you’ll need to accomplish 80 percent of modern data tasks.
Lander’s self-contained chapters start with the absolute basics, offering extensive hands-on practice and sample code. You’ll download and install R; navigate and use the R environment; master basic program control, data import, and manipulation; and walk through several essential tests. Then, building on this foundation, you’ll construct several complete models, both linear and nonlinear, and use some data mining techniques.
By the time you’re done, you won’t just know how to write R programs, you’ll be ready to tackle the statistical problems you care about most.
COVERAGE INCLUDES
• Exploring R, RStudio, and R packages
• Using R for math: variable types, vectors, calling functions, and more
• Exploiting data structures, including data.frames, matrices, and lists
• Creating attractive, intuitive statistical graphics
• Writing user-defined functions
• Controlling program flow with if, ifelse, and complex checks
• Improving program efficiency with group manipulations
• Combining and reshaping multiple datasets
• Manipulating strings using R’s facilities and regular expressions
• Creating normal, binomial, and Poisson probability distributions
• Programming basic statistics: mean, standard deviation, and t-tests
• Building linear, generalized linear, and nonlinear models
• Assessing the quality of models and variable selection
• Preventing overfitting, using the Elastic Net and Bayesian methods
• Analyzing univariate and multivariate time series data
• Grouping data via K-means and hierarchical clustering
• Preparing reports, slideshows, and web pages with knitr
• Building reusable R packages with devtools and Rcpp
• Getting involved with the R global community
Download the sample pages (includes Chapter 12 and Index)
Foreword xiii
Preface xv
Acknowledgments xix
About the Author xxi
Chapter 1: Getting R 11.1 Downloading R 1
1.2 R Version 2
1.3 32-bit vs. 64-bit 2
1.4 Installing 2
1.5 Revolution R Community Edition 10
1.6 Conclusion 11
Chapter 2: The R Environment 13
2.1 Command Line Interface 14
2.2 RStudio 15
2.3 Revolution Analytics RPE 26
2.4 Conclusion 27
Chapter 3: R Packages 29
3.1 Installing Packages 29
3.2 Loading Packages 32
3.3 Building a Package 33
3.4 Conclusion 33
Chapter 4: Basics of R 35
4.1 Basic Math 35
4.2 Variables 36
4.3 Data Types 38
4.4 Vectors 43
4.5 Calling Functions 49
4.6 Function Documentation 49
4.7 Missing Data 50
4.8 Conclusion 51
Chapter 5: Advanced Data Structures 53
5.1 data.frames 53
5.2 Lists 61
5.3 Matrices 68
5.4 Arrays 71
5.5 Conclusion 72
Chapter 6: Reading Data into R 73
6.1 Reading CSVs 73
6.2 Excel Data 74
6.3 Reading from Databases 75
6.4 Data from Other Statistical Tools 77
6.5 R Binary Files 77
6.6 Data Included with R 79
6.7 Extract Data from Web Sites 80
6.8 Conclusion 81
Chapter 7: Statistical Graphics 83
7.1 Base Graphics 83
7.2 ggplot2 86
7.3 Conclusion 98
Chapter 8: Writing R Functions 99
8.1 Hello, World! 99
8.2 Function Arguments 100
8.3 Return Values 103
8.4 do.call 104
8.5 Conclusion 104
Chapter 9: Control Statements 105
9.1 if and else 105
9.2 switch 108
9.3 ifelse 109
9.4 Compound Tests 111
9.5 Conclusion 112
Chapter 10: Loops, the Un-R Way to Iterate 113
10.1 for Loops 113
10.2 while Loops 115
10.3 Controlling Loops 115
10.4 Conclusion 116
Chapter 11: Group Manipulation 117
11.1 Apply Family 1