r_in_a_nutshell.pdf

(9093 KB) Pobierz
2
n
d
on
iti
Ed
IN A NUTSHELL
A Desktop Quick Reference
Joseph Adler
R
Mathematical & Statistical Software
R IN A NUTSHELL
If you’re considering R for statistical computing
and data visualization, this book provides a quick
and practical guide to just about everything you
can do with the open source R language and
software environment. You’ll learn how to write
R functions and use R packages to help you pre-
pare, visualize, and analyze data. Author Joseph
Adler illustrates each process with a wealth of
examples from medicine, business, and sports.
Updated for R 2.14 and 2.15, this second edition
includes new and expanded chapters on R
performance, the ggplot2 data visualization
package, and parallel R computing with Hadoop.
“ R is free and powerful, but
it’s difficult to get started.
R in a Nutshell
is a critical
companion for learning R
and is a great reference
manual for every data
scientist.”
—DJ Patil
Data Scientist in Residence
at Greylock
Get started quickly with an R tutorial and
hundreds of examples
Explore R syntax, objects, and other
language details
Find thousands of user-contributed R
packages online, including Bioconductor
Learn how to use R to prepare data for
analysis
Visualize your data with R’s graphics, lattice,
and ggplot2 packages
Use R to calculate statistical tests, fit
models, and compute probability
distributions
Speed up intensive computations by
writing parallel R programs for Hadoop
Get a complete desktop reference to R
“ R is fast becoming the lingua
franca of statistics, and
R in a
Nutshell
is the best entry point
for people getting started.
From data visualization to
time series analysis, the book
covers all the topics needed
to do powerful data science.”
—Anthony Goldbloom
Founder and CEO of Kaggle
Joseph Adler,
a senior data sci-
entist at LinkedIn, has years of
experience in data mining and
data analysis at companies
including DoubleClick, Amer-
ican Express, and VeriSign. He’s
the inventor of several patents
for computer security and cryp-
tography, and the author of
O’Reilly’s
Baseball Hacks.
Twitter: @oreillymedia
facebook.com/oreilly
US $49.99
CAN $52.99
ISBN: 978-1-449-31208-4
oreilly.com
IN A NUTSHELL
Second Edition
R
Joseph Adler
Beijing
Cambridge
Farnham
Köln
Sebastopol
Tokyo
R in a Nutshell, Second Edition
by Joseph Adler
Copyright © 2012 Joseph Adler. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online
editions are also available for most titles (http://safaribooksonline.com). For more information,
contact
our
corporate/institutional
sales
department:
800-998-9938
or
corporate@oreilly.com.
Editors:
Mike Loukides and Meghan Blanchette
Production Editor:
Holly Bauer
Proofreader:
Julie Van Keuren
Indexer:
Fred Brown
Cover Designer:
Karen Montgomery
Interior Designer:
David Futato
Illustrators:
Robert Romano and Re-
becca Demarest
September 2009:
October 2012:
First Edition.
Second Edition.
Revision History for the Second Edition:
2012-09-25
First release
2015-02-27
Second release
See
http://oreilly.com/catalog/errata.csp?isbn=9781449312084
for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trade-
marks of O’Reilly Media, Inc.
R in a Nutshell,
the image of a harpy eagle, and related trade
dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and O’Reilly Media,
Inc., was aware of a trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and
author assume no responsibility for errors or omissions, or for damages resulting from the use
of the information contained herein.
ISBN: 978-1-449-31208-4
[LSI]
1424708600
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Part I. R Basics
1. Getting and Installing R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
R Versions
Getting and Installing Interactive R Binaries
Windows
Mac OS X
Linux and Unix Systems
3
3
4
5
5
2. The R User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
The R Graphical User Interface
Windows
Mac OS X
Linux and Unix
The R Console
Command-Line Editing
Batch Mode
Using R Inside Microsoft Excel
RStudio
Other Ways to Run R
7
8
8
9
11
13
13
14
15
17
3. A Short R Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Basic Operations in R
Functions
Variables
19
21
22
iii
Zgłoś jeśli naruszono regulamin