Hadley Wickham &
Garrett Grolemund
R for Data
S c i e n c e
IMPORT, TIDY, TRANSFORM, VISUALIZE, AND MODEL DATA
Hadley Wickham and Garrett Grolemund
R for Data Science
Import, Tidy, Transform, Visualize,
and Model Data
Boston Farnham Sebastopol
Tokyo
Beijing Boston Farnham Sebastopol
Tokyo
Beijing
978-1-491-91039-9
[TI]
R for Data Science
by Hadley Wickham and Garrett Grolemund
Copyright © 2017 Garrett Grolemund, Hadley Wickham. All rights reserved.
Printed in Canada.
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://oreilly.com/safari). For more
information, contact our corporate/institutional sales department: 800-998-9938 or
corporate@oreilly.com.
Editors: Marie Beaugureau and
Mike Loukides
Production Editor: Nicholas Adams
Copyeditor: Kim Cofer
Proofreader: Charles Roumeliotis
Indexer: Wendy Catalano
Interior Designer: David Futato
Cover Designer: Karen Montgomery
Illustrator: Rebecca Demarest
December 2016: First Edition
Revision History for the First Edition
2016-12-06: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781491910399 for release details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. R for Data Sci‐
ence, the cover image, and related trade dress are trademarks of O’Reilly Media, Inc.
While the publisher and the authors have used good faith efforts to ensure that the
information and instructions contained in this work are accurate, the publisher and
the authors disclaim all responsibility for errors or omissions, including without
limitation responsibility for damages resulting from the use of or reliance on this
work. Use of the information and instructions contained in this work is at your own
risk. If any code samples or other technology this work contains or describes is sub‐
ject to open source licenses or the intellectual property rights of others, it is your
responsibility to ensure that your use thereof complies with such licenses and/or
rights.
Table of Contents
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Part I. Explore
1.
Data Visualization with ggplot2. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Introduction 3
First Steps 4
Aesthetic Mappings 7
Common Problems 13
Facets 14
Geometric Objects 16
Statistical Transformations 22
Position Adjustments 27
Coordinate Systems 31
The Layered Grammar of Graphics 34
2.
Workow: Basics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Coding Basics 37
What’s in a Name? 38
Calling Functions 39
3.
Data Transformation with dplyr. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Introduction 43
Filter Rows with filter() 45
Arrange Rows with arrange() 50
Select Columns with select() 51
iii
评论0
最新资源