Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Learning R
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
I. The R Language
1. Introduction
Chapter Goals
What Is R?
Installing R
Choosing an IDE
Emacs + ESS
Eclipse/Architect
RStudio
Revolution-R
Live-R
Other IDEs and Editors
Your First Program
How to Get Help in R
Installing Extra Related Software
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
2. A Scientific Calculator
Chapter Goals
Mathematical Operations and Vectors
Assigning Variables
Special Numbers
Logical Vectors
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
3. Inspecting Variables and Your Workspace
Chapter Goals
Classes
Different Types of Numbers
Other Common Classes
Checking and Changing Classes
Examining Variables
The Workspace
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
4. Vectors, Matrices, and Arrays
Chapter Goals
Vectors
Sequences
Lengths
Names
Indexing Vectors
Vector Recycling and Repetition
Matrices and Arrays
Creating Arrays and Matrices
Rows, Columns, and Dimensions
Row, Column, and Dimension Names
Indexing Arrays
Combining Matrices
Array Arithmetic
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
5. Lists and Data Frames
Chapter Goals
Lists
Creating Lists
Atomic and Recursive Variables
List Dimensions and Arithmetic
Indexing Lists
Converting Between Vectors and Lists
Combining Lists
NULL
Pairlists
Data Frames
Creating Data Frames
Indexing Data Frames
Basic Data Frame Manipulation
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
6. Environments and Functions
Chapter Goals
Environments
Functions
Creating and Calling Functions
Passing Functions to and from Other Functions
Variable Scope
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
7. Strings and Factors
Chapter Goals
Strings
Constructing and Printing Strings
Formatting Numbers
Special Characters
Changing Case
Extracting Substrings
Splitting Strings
File Paths
Factors
Creating Factors
Changing Factor Levels
Dropping Factor Levels
Ordered Factors
Converting Continuous Variables to Categorical
Converting Categorical Variables to Continuous
Generating Factor Levels
Combining Factors
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
8. Flow Control and Loops
Chapter Goals
Flow Control
if and else
Vectorized if
Multiple Selection
Loops
repeat Loops
while Loops
for Loops
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
9. Advanced Looping
Chapter Goals
Replication
Looping Over Lists
Looping Over Arrays
Multiple-Input Apply
Instant Vectorization
Split-Apply-Combine
The plyr Package
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
10. Packages
Chapter Goals
Loading Packages
The Search Path
Libraries and Installed Packages
Installing Packages
Maintaining Packages
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
11. Dates and Times
Chapter Goals
Date and Time Classes
POSIX Dates and Times
The Date Class
Other Date Classes
Conversion to and from Strings
Parsing Dates
Formatting Dates
Time Zones
Arithmetic with Dates and Times
Lubridate
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
II. The Data Analysis Workflow
12. Getting Data
Chapter Goals
Built-in Datasets
Reading Text Files
CSV and Tab-Delimited Files
Unstructured Text Files
XML and HTML Files
JSON and YAML Files
Reading Binary Files
Reading Excel Files
Reading SAS, Stata, SPSS, and MATLAB Files
Reading Other File Types
Web Data
Sites with an API
Scraping Web Pages
Accessing Databases
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
13. Cleaning and Transforming
Chapter Goals
Cleaning Strings
Manipulating Data Frames
Adding and Replacing Columns
Dealing with Missing Values
Converting Between Wide and Long Form
Using SQL
Sorting
Functional Programming
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
14. Exploring and Visualizing
Chapter Goals
Summary Statistics
The Three Plotting Systems
Scatterplots
Take 1: base Graphics
Take 2: lattice Graphics
Take 3: ggplot2 Graphics
Line Plots
Histograms
Box Plots
Bar Charts
Other Plotting Packages and Systems
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
15. Distributions and Modeling
Chapter Goals
Random Numbers
The sample Function
Sampling from Distributions
Distributions
Formulae
A First Model: Linear Regressions
Comparing and Updating Models
Plotting and Inspecting Models
Other Model Types
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
16. Programming
Chapter Goals
Messages, Warnings, and Errors
Error Handling
Debugging
Testing
RUnit
testthat
Magic
Turning Strings into Code
Turning Code into Strings
Object-Oriented Programming
S3 Classes
Reference Classes
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
17. Making Packages
Chapter Goals
Why Create Packages?
Prerequisites
The Package Directory Structure
Your First Package
Documenting Packages
Checking and Building Packages
Maintaining Packages
Summary
Test Your Knowledge: Quiz
Test Your Knowledge: Exercises
III. Appendixes
A. Properties of Variables
B. Other Things to Do in R
C. Answers to Quizzes
D. Solutions to Exercises
E. Bibliography
Index
About the Author
Colophon
Copyright
← Prev
Back
Next →
← Prev
Back
Next →