Books & Videos

Table of Contents

  1. Chapter 1 Getting Started and Getting Help

    1. Introduction

    2. Downloading and Installing R

    3. Starting R

    4. Entering Commands

    5. Exiting from R

    6. Interrupting R

    7. Viewing the Supplied Documentation

    8. Getting Help on a Function

    9. Searching the Supplied Documentation

    10. Getting Help on a Package

    11. Searching the Web for Help

    12. Finding Relevant Functions and Packages

    13. Searching the Mailing Lists

    14. Submitting Questions to the Mailing Lists

  2. Chapter 2 Some Basics

    1. Introduction

    2. Printing Something

    3. Setting Variables

    4. Listing Variables

    5. Deleting Variables

    6. Creating a Vector

    7. Computing Basic Statistics

    8. Creating Sequences

    9. Comparing Vectors

    10. Selecting Vector Elements

    11. Performing Vector Arithmetic

    12. Getting Operator Precedence Right

    13. Defining a Function

    14. Typing Less and Accomplishing More

    15. Avoiding Some Common Mistakes

  3. Chapter 3 Navigating the Software

    1. Introduction

    2. Getting and Setting the Working Directory

    3. Saving Your Workspace

    4. Viewing Your Command History

    5. Saving the Result of the Previous Command

    6. Displaying the Search Path

    7. Accessing the Functions in a Package

    8. Accessing Built-in Datasets

    9. Viewing the List of Installed Packages

    10. Installing Packages from CRAN

    11. Setting a Default CRAN Mirror

    12. Suppressing the Startup Message

    13. Running a Script

    14. Running a Batch Script

    15. Getting and Setting Environment Variables

    16. Locating the R Home Directory

    17. Customizing R

  4. Chapter 4 Input and Output

    1. Introduction

    2. Entering Data from the Keyboard

    3. Printing Fewer Digits (or More Digits)

    4. Redirecting Output to a File

    5. Listing Files

    6. Dealing with “Cannot Open File” in Windows

    7. Reading Fixed-Width Records

    8. Reading Tabular Data Files

    9. Reading from CSV Files

    10. Writing to CSV Files

    11. Reading Tabular or CSV Data from the Web

    12. Reading Data from HTML Tables

    13. Reading Files with a Complex Structure

    14. Reading from MySQL Databases

    15. Saving and Transporting Objects

  5. Chapter 5 Data Structures

    1. Introduction

    2. Appending Data to a Vector

    3. Inserting Data into a Vector

    4. Understanding the Recycling Rule

    5. Creating a Factor (Categorical Variable)

    6. Combining Multiple Vectors into One Vector and a Factor

    7. Creating a List

    8. Selecting List Elements by Position

    9. Selecting List Elements by Name

    10. Building a Name/Value Association List

    11. Removing an Element from a List

    12. Flatten a List into a Vector

    13. Removing NULL Elements from a List

    14. Removing List Elements Using a Condition

    15. Initializing a Matrix

    16. Performing Matrix Operations

    17. Giving Descriptive Names to the Rows and Columns of a Matrix

    18. Selecting One Row or Column from a Matrix

    19. Initializing a Data Frame from Column Data

    20. Initializing a Data Frame from Row Data

    21. Appending Rows to a Data Frame

    22. Preallocating a Data Frame

    23. Selecting Data Frame Columns by Position

    24. Selecting Data Frame Columns by Name

    25. Selecting Rows and Columns More Easily

    26. Changing the Names of Data Frame Columns

    27. Editing a Data Frame

    28. Removing NAs from a Data Frame

    29. Excluding Columns by Name

    30. Combining Two Data Frames

    31. Merging Data Frames by Common Column

    32. Accessing Data Frame Contents More Easily

    33. Converting One Atomic Value into Another

    34. Converting One Structured Data Type into Another

  6. Chapter 6 Data Transformations

    1. Introduction

    2. Splitting a Vector into Groups

    3. Applying a Function to Each List Element

    4. Applying a Function to Every Row

    5. Applying a Function to Every Column

    6. Applying a Function to Groups of Data

    7. Applying a Function to Groups of Rows

    8. Applying a Function to Parallel Vectors or Lists

  7. Chapter 7 Strings and Dates

    1. Introduction

    2. Getting the Length of a String

    3. Concatenating Strings

    4. Extracting Substrings

    5. Splitting a String According to a Delimiter

    6. Replacing Substrings

    7. Seeing the Special Characters in a String

    8. Generating All Pairwise Combinations of Strings

    9. Getting the Current Date

    10. Converting a String into a Date

    11. Converting a Date into a String

    12. Converting Year, Month, and Day into a Date

    13. Getting the Julian Date

    14. Extracting the Parts of a Date

    15. Creating a Sequence of Dates

  8. Chapter 8 Probability

    1. Introduction

    2. Counting the Number of Combinations

    3. Generating Combinations

    4. Generating Random Numbers

    5. Generating Reproducible Random Numbers

    6. Generating a Random Sample

    7. Generating Random Sequences

    8. Randomly Permuting a Vector

    9. Calculating Probabilities for Discrete Distributions

    10. Calculating Probabilities for Continuous Distributions

    11. Converting Probabilities to Quantiles

    12. Plotting a Density Function

  9. Chapter 9 General Statistics

    1. Introduction

    2. Summarizing Your Data

    3. Calculating Relative Frequencies

    4. Tabulating Factors and Creating Contingency Tables

    5. Testing Categorical Variables for Independence

    6. Calculating Quantiles (and Quartiles) of a Dataset

    7. Inverting a Quantile

    8. Converting Data to Z-Scores

    9. Testing the Mean of a Sample (t Test)

    10. Forming a Confidence Interval for a Mean

    11. Forming a Confidence Interval for a Median

    12. Testing a Sample Proportion

    13. Forming a Confidence Interval for a Proportion

    14. Testing for Normality

    15. Testing for Runs

    16. Comparing the Means of Two Samples

    17. Comparing the Locations of Two Samples Nonparametrically

    18. Testing a Correlation for Significance

    19. Testing Groups for Equal Proportions

    20. Performing Pairwise Comparisons Between Group Means

    21. Testing Two Samples for the Same Distribution

  10. Chapter 10 Graphics

    1. Introduction

    2. Creating a Scatter Plot

    3. Adding a Title and Labels

    4. Adding a Grid

    5. Creating a Scatter Plot of Multiple Groups

    6. Adding a Legend

    7. Plotting the Regression Line of a Scatter Plot

    8. Plotting All Variables Against All Other Variables

    9. Creating One Scatter Plot for Each Factor Level

    10. Creating a Bar Chart

    11. Adding Confidence Intervals to a Bar Chart

    12. Coloring a Bar Chart

    13. Plotting a Line from x and y Points

    14. Changing the Type, Width, or Color of a Line

    15. Plotting Multiple Datasets

    16. Adding Vertical or Horizontal Lines

    17. Creating a Box Plot

    18. Creating One Box Plot for Each Factor Level

    19. Creating a Histogram

    20. Adding a Density Estimate to a Histogram

    21. Creating a Discrete Histogram

    22. Creating a Normal Quantile-Quantile (Q-Q) Plot

    23. Creating Other Quantile-Quantile Plots

    24. Plotting a Variable in Multiple Colors

    25. Graphing a Function

    26. Pausing Between Plots

    27. Displaying Several Figures on One Page

    28. Opening Additional Graphics Windows

    29. Writing Your Plot to a File

    30. Changing Graphical Parameters

  11. Chapter 11 Linear Regression and ANOVA

    1. Introduction

    2. Performing Simple Linear Regression

    3. Performing Multiple Linear Regression

    4. Getting Regression Statistics

    5. Understanding the Regression Summary

    6. Performing Linear Regression Without an Intercept

    7. Performing Linear Regression with Interaction Terms

    8. Selecting the Best Regression Variables

    9. Regressing on a Subset of Your Data

    10. Using an Expression Inside a Regression Formula

    11. Regressing on a Polynomial

    12. Regressing on Transformed Data

    13. Finding the Best Power Transformation (Box–Cox Procedure)

    14. Forming Confidence Intervals for Regression Coefficients

    15. Plotting Regression Residuals

    16. Diagnosing a Linear Regression

    17. Identifying Influential Observations

    18. Testing Residuals for Autocorrelation (Durbin–Watson Test)

    19. Predicting New Values

    20. Forming Prediction Intervals

    21. Performing One-Way ANOVA

    22. Creating an Interaction Plot

    23. Finding Differences Between Means of Groups

    24. Performing Robust ANOVA (Kruskal–Wallis Test)

    25. Comparing Models by Using ANOVA

  12. Chapter 12 Useful Tricks

    1. Introduction

    2. Peeking at Your Data

    3. Widen Your Output

    4. Printing the Result of an Assignment

    5. Summing Rows and Columns

    6. Printing Data in Columns

    7. Binning Your Data

    8. Finding the Position of a Particular Value

    9. Selecting Every nth Element of a Vector

    10. Finding Pairwise Minimums or Maximums

    11. Generating All Combinations of Several Factors

    12. Flatten a Data Frame

    13. Sorting a Data Frame

    14. Sorting by Two Columns

    15. Stripping Attributes from a Variable

    16. Revealing the Structure of an Object

    17. Timing Your Code

    18. Suppressing Warnings and Error Messages

    19. Taking Function Arguments from a List

    20. Defining Your Own Binary Operators

  13. Chapter 13 Beyond Basic Numerics and Statistics

    1. Introduction

    2. Minimizing or Maximizing a Single-Parameter Function

    3. Minimizing or Maximizing a Multiparameter Function

    4. Calculating Eigenvalues and Eigenvectors

    5. Performing Principal Component Analysis

    6. Performing Simple Orthogonal Regression

    7. Finding Clusters in Your Data

    8. Predicting a Binary-Valued Variable (Logistic Regression)

    9. Bootstrapping a Statistic

    10. Factor Analysis

  14. Chapter 14 Time Series Analysis

    1. Introduction

    2. Representing Time Series Data

    3. Plotting Time Series Data

    4. Extracting the Oldest or Newest Observations

    5. Subsetting a Time Series

    6. Merging Several Time Series

    7. Filling or Padding a Time Series

    8. Lagging a Time Series

    9. Computing Successive Differences

    10. Performing Calculations on Time Series

    11. Computing a Moving Average

    12. Applying a Function by Calendar Period

    13. Applying a Rolling Function

    14. Plotting the Autocorrelation Function

    15. Testing a Time Series for Autocorrelation

    16. Plotting the Partial Autocorrelation Function

    17. Finding Lagged Correlations Between Two Time Series

    18. Detrending a Time Series

    19. Fitting an ARIMA Model

    20. Removing Insignificant ARIMA Coefficients

    21. Running Diagnostics on an ARIMA Model

    22. Making Forecasts from an ARIMA Model

    23. Testing for Mean Reversion

    24. Smoothing a Time Series

  1. Colophon