没有合适的资源?快使用搜索试试~ 我知道了~
首页R Cookbook 原版pdf by Teetor
R Cookbook 原版pdf by Teetor
需积分: 35 116 浏览量
更新于2023-05-24
评论 1
收藏 9.36MB PDF 举报
R is a powerful tool for statistics, graphics, and statistical programming. It is used by tens of thousands of people daily to perform serious statistical analyses. It is a free, open source system whose implementation is the collective accomplishment of many intelligent, hard-working people. There are more than 2,000 available add-ons, and R is a serious rival to all commercial statistical packages. But R can be frustrating. It’s not obvious how to accomplish many tasks, even simple ones. The simple tasks are easy once you know how, yet figuring out that “how” can be maddening.
资源详情
资源评论
资源推荐


R Cookbook
Paul Teetor
Beijing
•
Cambridge
•
Farnham
•
Köln
•
Sebastopol
•
Tokyo

R Cookbook
by Paul Teetor
Copyright © 2011 Paul Teetor. 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://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.
Editor: Mike Loukides
Production Editor: Adam Zaremba
Copyeditor: Matt Darnell
Proofreader: Jennifer Knight
Indexer: Jay Marchand
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrator: Robert Romano
Printing History:
March 2011: First Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. R Cookbook, 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 authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-0-596-80915-7
[LSI]
1299102737

Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
1. Getting Started and Getting Help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1
Downloading and Installing R 2
1.2 Starting R 4
1.3
Entering Commands 7
1.4 Exiting from R 8
1.5
Interrupting R 9
1.6
Viewing the Supplied Documentation 10
1.7
Getting Help on a Function 11
1.8 Searching the Supplied Documentation 13
1.9 Getting Help on a Package 14
1.10 Searching the Web for Help 16
1.11 Finding Relevant Functions and Packages 18
1.12 Searching the Mailing Lists 19
1.13 Submitting Questions to the Mailing Lists 20
2. Some Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.1
Printing Something 23
2.2
Setting Variables 25
2.3
Listing Variables 26
2.4
Deleting Variables 27
2.5
Creating a Vector 28
2.6
Computing Basic Statistics 30
2.7
Creating Sequences 32
2.8
Comparing Vectors 34
2.9
Selecting Vector Elements 35
2.10
Performing Vector Arithmetic 38
2.11
Getting Operator Precedence Right 40
2.12
Defining a Function 41
2.13
Typing Less and Accomplishing More 43
v

2.14 Avoiding Some Common Mistakes 46
3. Navigating the Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
3.1 Getting and Setting the Working Directory 51
3.2 Saving Your Workspace 52
3.3 Viewing Your Command History 53
3.4 Saving the Result of the Previous Command 53
3.5 Displaying the Search Path 54
3.6 Accessing the Functions in a Package 55
3.7 Accessing Built-in Datasets 57
3.8 Viewing the List of Installed Packages 58
3.9
Installing Packages from CRAN 59
3.10
Setting a Default CRAN Mirror 61
3.11
Suppressing the Startup Message 62
3.12
Running a Script 62
3.13
Running a Batch Script 63
3.14 Getting and Setting Environment Variables 66
3.15
Locating the R Home Directory 67
3.16 Customizing R 68
4. Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.1
Entering Data from the Keyboard 72
4.2
Printing Fewer Digits (or More Digits) 73
4.3
Redirecting Output to a File 74
4.4
Listing Files 75
4.5
Dealing with “Cannot Open File” in Windows 76
4.6
Reading Fixed-Width Records 77
4.7
Reading Tabular Data Files 78
4.8
Reading from CSV Files 80
4.9
Writing to CSV Files 82
4.10
Reading Tabular or CSV Data from the Web 83
4.11
Reading Data from HTML Tables 84
4.12
Reading Files with a Complex Structure 86
4.13
Reading from MySQL Databases 89
4.14
Saving and Transporting Objects 92
5. Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
5.1 Appending Data to a Vector 101
5.2 Inserting Data into a Vector 103
5.3 Understanding the Recycling Rule 103
5.4 Creating a Factor (Categorical Variable) 105
5.5
Combining Multiple Vectors into One Vector and a Factor 107
5.6
Creating a List 108
vi | Table of Contents
剩余430页未读,继续阅读

















安全验证
文档复制为VIP权益,开通VIP直接复制

评论0