Professional Documents
Culture Documents
R
2.3.0 (2006-04-24)
0.1 (2006-06-15)
W. N. Venables, D. M. Smith
R the R Development Core Team
ii
:
c
Copyright 1990 W. N. Venables
c
Copyright 1992 W. N. Venables & D. M. Smith
c
Copyright 1997 R. Gentleman & R. Ihaka
c
Copyright 1997, 1998 M. Maechler
c
Copyright 19992006 R Development Core Team
Permission is granted to make and distribute verbatim copies of this manual provided the
copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the
conditions for verbatim copying, provided that the entire resulting derived work is distributed
under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another
language, under the above conditions for modified versions, except that this permission notice
may be stated in a translation approved by the R Development Core Team.
c
1990 W. N. Venables
c
1992 W. N. Venables & D. M. Smith
c
1997 R. Gentleman & R. Ihaka
c
1997, 1998 M. Maechler
c
19992006 R Development Core Team
GNU FDLGNU
http://www.gnu.org/copyleft/fdl.html
viii
0.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . viii
0.2 (05) . . . . . . . . . . . . . . . . . . . . . . . . viii
0.3 (PDF) . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
1 1
1.1 R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5 R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.6 R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.7 . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.8 R . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.9 . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.10 . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 8
2.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.7 . . . . . . . . . . . . . . . . . 13
2.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
iv
3 16
3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4 20
4.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2 tapply() . . . . . . . . . . . . . . . . . . . . . . . . 21
4.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5 23
5.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.4 array() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5.4.1 . . . . . . . . . . . . . . . 26
5.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.7.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.7.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
5.7.3 . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.7.4 . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.7.5 QR . . . . . . . . . . . . . . . . . . . . . 31
5.8 cbind() rbind() . . . . . . . . . . . . . . . . . . . . 31
5.9 c() . . . . . . . . . . . . . . . . . . . . . . . 32
5.10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6 34
6.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
6.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
6.2.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
6.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
6.3.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
6.3.2 attach() detach() . . . . . . . . . . . . . . . . . . . . . . . . 36
6.3.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
v
6.3.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.3.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
7 39
7.1 read.table() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
7.2 scan() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
7.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
7.3.1 R . . . . . . . . . . . . . . . . . . . . . . 42
7.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
8 43
8.1 R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
8.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
8.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
9 52
9.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
9.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
9.2.1 if . . . . . . . . . . . . . . . . . . . . . . . . . . 52
9.2.2 forrepeat while . . . . . . . . . . . . . . . 53
10 54
10.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
10.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
10.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
10.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
10.6.1 . . . . . . . . . . . . . . . . . . . . . . . . 57
10.6.2 . . . . . . . . . . . . . . . . . . . . . . . . 58
10.6.3 . . . . . . . . . . . . . . . . . . . . . . . . . . 59
10.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
10.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
10.9 . . . . . . . . . . . . . . . . . . . . . . . . . . 63
11 R 66
11.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
11.1.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
vi
11.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
11.3 . . . . . . . . . . . . . . . . . . . . . . . . . . 70
11.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
11.4.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
11.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
11.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
11.6.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
11.6.2 glm() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
11.7 . . . . . . . . . . . . . . . . . . . . 78
11.7.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
11.7.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
11.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
12 83
12.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
12.1.1 plot() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
12.1.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
12.1.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
12.1.4 . . . . . . . . . . . . . . . . . . . . . . . . . 86
12.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
12.2.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
12.2.2 Hershey . . . . . . . . . . . . . . . . . . . . . . . . . . 89
12.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
12.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
12.4.1 : par() . . . . . . . . . . . . . . . . . . . . . . 90
12.4.2 . . . . . . . . . . . . . . . . . . 91
12.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
12.5.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
12.5.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
12.5.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
12.5.4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
12.6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
12.6.1 PostScript . . . . . . . . . . . . . . . . . . . . 97
12.6.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
12.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
vii
13 100
13.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
13.2 CRAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
13.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
1 102
2 R 108
13.4 R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
13.5 Windows R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
13.6 Mac OS X R . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
3 114
13.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
13.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
13.9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
4 116
5 118
6 122
0.1
R A session<102>
R R sessions
R
R
(<83> )
R
http://cran.r-project.org/mirrors.html
Precompiled Binary Distributions
Windows Windows (95 and later)base
rwxxxx.exerw2010.exeWindows OK
A session<102>
0.2 (05)
R R
R R
R
0.2 (05) ix
ROTATION R
StataMATLABSPSS SAS R
R
R
R MATLAB
R
R R
R /R
R R
R
http://www.r-project.org/
foundation/about.html
Texinfo Texinfo PDF
HTML (UTF-8)
Texinfo LaTeXPDF
email
PDF
R
R An Introduction to R
R Data Import/ExportThe R language definitionWriting R
ExtensionsR Installation and Administration/R FAQ
0.3 (PDF) x
R
R
Shigeru MASE
Emailghding@gmail.com
200563
0.3 (PDF)
RLATEX
R
Email
R R
Emmanuel Paradis R for beginnersXF Wang
R for beginners R: )
Texinfo
LATEX
|!
PDFDr. ZP LiDr. RuiLi
Rui
Prof Li
Brian D. Ripley Technische Uni. Wien Friedrich Leisch
R
Ronggui
H Li
- Q Wang K Tu
(CHMRK TuG Li
Q Liu
0.3 (PDF) xi
Roation RR
LATEXR
Email
Emailghding@gmail.com
2006711
1.1 R
R
(S)
S
, environment R
, ,
R
packages R
1.2
R Bell LaboratoriesRick BeckerJohn Chambers
Allan Wilks S S SPLUS
S John Chambers
RRichard A. BeckerJohn M. Chambers Allan R.
1.3 R 2
Wilks The New S Language: A Programming Environment for Data Analysis and
GraphicsJohn M. Chambers and Trevor J. Hastie Statistical Models in S
1991 S 3 1 methods method
classJohn M. Chambers Programming with Data
<122>.
R S/SPLUS
R R S R R
1.3 R
R R
R
R
25 R
CRAN (http://CRAN.R-project.org)
(<100>)
R
S( R) S
object
SAS SPSS R
R
2
1.4 R
graphics workstation
R R
RX window R
. ,
UNIX Windows MacOS R
1
: John M. Chambers 1988S3
2
: R.
1.5 R 3
1.5 R
R
>UNIX shell
R
UNIX shell $
UNIX R
1. work R
R
$ mkdir work
$ cd work
2. R
$ R
3. R ()
4. R
> q()
R
yesno,
cancel
R R
1. work
$ cd work
$ R
2. R q()
1.6 R 4
Windows R
R 3 R
1.6 R
R
<102> R R
1.7
R UNIXman
solve
> help(solve)
> ?solve
iffor function
> help("[[")
escape"Its important"4
R HTML
> help.start()
UNIX
HTML help.start()
Search Engine & Keywords
R
3
R
OK
4
Its important R
1.8 R 5
help.search 5 ?help.search
Windows R
6
> ?help
1.8 R
R expression language
A a R
R (locale )
. ().
.
expressionsassignments
evaluate
(;)({})
compound expression7
(#)
R
continuation prompt
5
?
6
: BioConductor Vignettes .
7
1.9 6
1.9
UNIX Windows R
command history
DEL <
114>.
UNIX
readline
Emacs 8 R (ESS
Emacs Speaks Statistics)R: R
1.10
work commands.R
R
> source("commands.R")
Windows R FileSource
sink
> sink("record.lis")
9 record.lis
> sink()
1.11
R entity
structures
8
ViUltraEditUltraEdit R http://
www.ultraedit.com/index.php?name=Content&pa=showpage&pid=40 R wordfile R Scripting
- 02/18/2003UltraEdit wordfile.txt
.R
9
1.11 7
R (
) R (ls())
> objects()
R
workspace
rm
R R
R
.RData10
.Rhistory
R
R
x y
10
UNIX
2.1
R data structure
vector
x10.45.63.16.4 21.7 R
c() c()
1
R 1
(<-)< () - ()
2
=
assign()
<-
3
1
c() list <
35>
2
-><--<>-
3
.Last.value
2.2 9
> 1/x
(x )
11yx 0
2.2
recycled(
)
11v2*x 2.2y 1 11
+-*/ ^
logexpsincostansqrt
max min range
2c(min(x), max(x)) length(x) x sum(x)
x prod(x)
mean(x) sum(x)/length(x)
var(x)var(x)
> sum((x-mean(x))^2)/(length(x)-1)
var() np p-
pp
sort(x) x
(order() sort.list())
max min
parallel
pmax pmin
2.3 10
> sqrt(-17)
NaN
> sqrt(-17+0i)
2.3
R 1:30 c(1, 2, ..., 29, 30)
R2*1:15 c(2, 4, ..., 28, 30)
n <- 101:n-11:(n-1)
30:1 construction
seq()
seq(2,10) 2:10
seq() R
from=value to=value
seq(1,30)seq(from=1, to=30)seq(to=30, from=1) 1:30
seq() by=value length=value
by=11
s4
2.4 11
along=vector 4
1, 2, ..., length(vector )vector
rep()
x x s5
2.4
R
TRUEFALSE NA (, )T F
T F TRUE FALSE reserved
wordTRUE
FALSE
conditions
, temp x FALSE x
TRUE
R <<=>>= ==
!= c1 c2 c1 & c2
()c1 | c2 ()!c1 c1
FALSE
0 TRUE 1
4
length(vector )
2.5 12
2.5
not available missing value
NA5 NA NA
is.na(x) x TRUE x
NA
x == NA is.na(x) NA
, x == NA x
NA
Not a NumberNaN
> 0/0
NaN
NA NaN is.na(xx) TRUEis.nan(xx)
NaN TRUE
<NA> 6
> a<-c("a","b",NA)
> a
[1] "a" "b" NA
> print(a,quote=F)
[1] a b <NA>
5
0.01, PDF
6
2.6 13
2.6
R
"x-values""New iteration results"
(") ()
()C escape
sequences\ \ \ "
\"\n\t\b
c()
paste()
sep=string
string
labs
c("X1", "Y2", "X3", "Y4", "X5", "Y6", "X7", "Y8", "X9", "Y10")
c("X", "Y") 5
1:10 7
2.7
subset
1.
TRUE FALSE
()x yx
y x
z x+1 x
2. {1, 2, . . . , length(x)}
x[6]x
> x[1:10]
x 10(length(x) 10)
3. 8
x y
4. names
vector[indexv ector ]
0x
2.8
R
matrixarray
<23>
factor<20>.
listgeneral form
<34>.
data frame
<36>
function R R
<54>
3.1
R object
atomic
1 R 2 numericcomplex
logicalcharacterraw
(NA
NA)
character(0) numeric(0)
R R list
functionexpression R
R R
formulae
mode
propertylength
mode(object) length(object) 3
attributes(object)
<18>.
z 100 mode(z)
"complex" length(z) 100
R ()
1
R typeof()S
2
integerdouble
3
length(object) object
3.2 17
d z 4 as.something()
3.2
echaracter()
3e(NA)
scan()(scan()
<40>.)
alpha
10
5(
)
4
roundoff
5
3.3 18
3.3
attributes(object) non-intrinsic at-
tributesattr(object, name)
6 ,
object
,
R z 1010
3.4
R classclass
"numeric""logical""character" "list"
"matrix""array""factor" "data.frame"
7 R
"data.frame" 8 plot()
9 generic functionsummary()
unclass() winter
"data.frame"
> winter
> unclass(winter)
6
:attributes(object). ,
. str(object).
7
methods S4
8
: print
9
Java C++ Java 1.5 5.0
3.4 19
<63>
factor R
orderedunordered
(<69>)
4.1
301
state
> state <- c("tas", "sa", "qld", "nsw", "nsw", "nt", "wa", "wa",
"qld", "vic", "nsw", "vic", "qld", "qld", "sa", "tas",
"sa", "nt", "wa", "vic", "qld", "nsw", "nsw", "wa",
"sa", "act", "nsw", "vic", "vic", "act")
2
factor()
print()
> statef
[1] tas sa qld nsw nsw nt wa wa qld vic nsw vic qld qld sa
[16] tas sa nt wa vic qld nsw nsw wa sa act nsw vic vic act
Levels: act nsw nt qld sa tas vic wa
levels() levels
> levels(statef)
[1] "act" "nsw" "nt" "qld" "sa" "tas" "vic" "wa"
1
8Australian Capital Territory, New South Wales, the Northern
Territory, Queensland, South Australia, Tasmania, Victoria Western Australia
2
: , .
4.2 tapply() 21
4.2 tapply()
()
> incomes <- c(60, 49, 40, 61, 64, 60, 59, 54, 62, 69, 70, 42, 56,
61, 61, 61, 58, 51, 48, 65, 49, 49, 41, 48, 52, 46,
59, 46, 58, 43)
tapply()
standard error4
R var()
(<54>
R sd()5 )
3
tapply() tapply(incomes, state)
R as.factor()
4
5
: . R sd(),
stderr(1:4)sd(1:4). stderr <-
function(x){sd(x)/sqrt(length(x))}
4.3 22
> incster
act nsw nt qld sa tas vic wa
1.5 4.3102 4.5 4.1061 2.7386 0.5 5.244 2.6575
95%
tapply() length()t-
qt()( R t-)
tapply()
()
ragged array
4.3
factor
ordered()
ordered() factor
,
5.1
R
dimension vectork
k-2-1
dim R z1500
dim 3 5 100
matrix() array() array()
<26>.
data vector FORTRAN
5.2
a[2,,] 4 2 c(4,2)
5.3 24
a[,,]a
Zdim(Z) (
)
5.3
4 5 X
X 0
3 2
5.3 25
blocks(b)varieties
(v )n
table()
5.4 array()
dim array
h 24
h Z 3 4 2 h 24
h 2424 (
<26>)
Z 0
dim(Z) c(3,4,2)Z[1:24] h
Z[] Z
dim
A, B C
5.4.1
5.5 27
dim
1
dim
5.5
outer producta b
()a b
%o%
f (x; y) = cos(y)/(1 + x2 ) R x yregular grid
(1)
R <
54>.
2 2
2 2 [a, b; c, d]
0, 1, . . . , 9
ad bchigh
density
outer()
1
: As long as short vectors and arrays only are encountered, the arrays must all have
the same dim attribute or an error results.
5.6 28
names
for <52>
202
5.6
aperm(a, perm) aperm {1, . . . , k}
k a a
perm[j]j
A( )B
A t()
B <- t(A)
5.7
R t(X)
nrow(A) ncol(A) A
5.7.1
%*% n 1 1 n
n
A B
> A * B
2
: It is also perhaps surprising that about 1 in 20 such matrices is singular.
5.7 29
> A %*% B
quadratic form3
crossprod() crossproductcrossprod(X,
y) t(X) %*% y crossprod()
diag() v diag(v)
M diag(M) M
Matlab diag() k 4
diag(k) k k
5.7.2
A bx R
> solve(A,b)
x ()
x = A1 b A1 Ainverse
solve(A)
x0 A1 x5 x %*% solve(A,x)
A
3
x %*% x x0 x xx0 x
x0 x
xx0 cbind(x) %*% x x %*% rbind(x) rbind() cbind()
x0 x xx0 crossprod(x) x %o% x
4
.
5
A = BB 0 B A Cholesky
By = x squared length
Even better would be to form a matrix square root B with A = BB 0 and find the squared length
of the solution of By = x, perhaps using the Cholesky or eigendecomposition of A.
5.7 30
5.7.3
eigen(Sm) Sm
values vectors
evev$val Sm ev$vec
evals
> eigen(Sm)
5.7.4
svd(M) M, M
M U M V
D M = U %*% D %*% t(V)D
svd(M) d, u v
M
M
R
, absdet() R
tracetr() [: ,
diag()]
R det
5.7.5 QR
lsfit() Least squares fitting
y X
regression diagnostics
ls.diag()X
lm(.) (<70>)
lsfit()
qr()
y fit X res b
b Matlab
X
R
<66>
cbind()
arg1 , arg2 , . . .
cbind()
()
5.9 c() 32
rbind()
X1 X2 X
1
5.9 c()
cbind() rbind() dim c()
dim dimnames
as.vector()
c()
(
)
5.10
table() k
k-
statef
statefr
incomef
cut()
> table(incomef,statef)
statef
incomef act nsw nt qld sa tas vic wa
(35,45] 1 1 0 1 0 0 1 0
(45,55] 1 1 1 1 2 0 1 3
(55,65] 0 3 1 3 2 2 2 1
(65,75] 0 1 0 0 0 0 1 0
6.1
R list
components
numbered
Lst Lst[[1]], Lst[[2]], Lst[[3]] Lst[[4]]
Lst[[4]] Lst[[4]][1]
Lst length(Lst) (
)
Lst$name Lst[[1]] "Fred",
Lst$wife Lst[[2]] "Mary",
Lst$child.ages[1] Lst[[4]][1] 4
6.2 35
Lst$name
Lst[["name"]]
2 Lst$coefficients
Lst$coe Lst$covariance Lst$cov
(names)
6.2
list()
m Lstobject 1 , . . . , object m
6.2.1
c()
dim
6.3
data frame"data.frame"
(, , );
6.3.1
data.frame ()
as.data.frame()
read.table()
<39>
attach()
lentils lentils$u, lentils$v, lentils$w
> attach(lentils)
6.3 37
2position 23 1u, v w
u, v w
u1u
4 $
u 5
> detach()
2u, v w
lentils$u
2detach
detach(lentils) detach("lentils")
R 2
(
)6
6.3.3
,
;
21
$
detach()
3
R 1attach()
2
4
:1u, u <- v + w, 1u.
5
: u, u, .
6
: R, .
6.3 38
x, y z
6.3.4
attach()
"list"
> attach(any.old.list)
detach
6.3.5
search
()
> search()
[1] ".GlobalEnv" "Autoloads" "package:base"
.GlobalEnv 7
lentils
> search()
[1] ".GlobalEnv" "lentils" "Autoloads" "package:base"
> ls(2)
[1] "u" "v" "w"
ls (objects)
> detach("lentils")
> search()
[1] ".GlobalEnv" "Autoloads" "package:base"
7
autoload
R R
R
Perl1
R
read.table()
scan()2 ,
R R /3
7.1 read.table()
1
UNIXSed Awk
2
read.table()scan()Excel
3
R
4
R
read.table() header=TRUE
7.2 scan() 40
(),
Cent.heat
read.table()
header=TRUE
7.2 scan()
input.datscan()
2(<38>)
7.3
R 100(datasets )(R
)
data()
R 2.0.0R
data R
data(infert)
()
R
7.4 42
7.3.1 R
package
data(package="rpart")
data(Puromycin, package="datasets")
library R
7.4
edit R
xoldxnew
xoldfix(xold)xold <- edit(xold)
8.1 R
R R P (X
x)(qP (X x) > q x
)
R
beta shape1, shape2, ncp
binom size, prob
Cauchy cauchy location, scale
chisq df, ncp
exp rate
F f df1, df1, ncp
gamma shape, scale
geom prob
hyper m, n, k
lnorm meanlog, sdlog
logistic logis location, scale
nbinom size, prob
norm mean, sd
Poisson pois lambda
t t df, ncp
unif min, max
Weibull weibull shape, scale
Wilcoxon wilcox m, n
d p
cumulative distribution functionCDF q r
8.2 44
> ## tp
> 2*pt(-2.43, df = 13)
> ## F(2, 7)1%
> qf(0.99, 2, 7)
8.2
summary fivenum stem
()
1
In not quite all cases is the non-centrality parameter ncp are currently available...
8.2 45
> attach(faithful)
> summary(eruptions)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.600 2.163 4.000 3.488 4.454 5.100
> fivenum(eruptions)
[1] 1.6000 2.1585 4.0000 4.4585 5.1000
> stem(eruptions)
16 | 070355555588
18 | 000022233333335577777777888822335777888
20 | 00002223378800035778
22 | 0002335578023578
24 | 00228
26 | 23
28 | 080
30 | 7
32 | 2337
34 | 250077
36 | 0000823577
38 | 2333335582225577
40 | 0000003357788888002233555577778
42 | 03335555778800233333555577778
44 | 02222335557780000000023333357778888
46 | 0000233357700000023578
48 | 00000022335800333
50 | 0370
R hist
> hist(eruptions)
> ##
> hist(eruptions, seq(1.6, 5.2, 0.2), prob=TRUE)
> lines(density(eruptions, bw=0.1))
> rug(eruptions) #
density
density trial-and-errorbwbandwidth
(2 bw = "SJ"
2
?density?bw.nrd
8.2 46
Histogram of eruptions
0.7
0.6
0.5
Relative Frequency
0.4
0.3
0.2
0.1
0.0
eruptions
par(pty="s") #
qqnorm(long); qqline(long)
QQ
t
x <- rt(250, df = 5)
qqnorm(x); qqline(x)
8.2 47
ecdf(long)
1.0
0.8
0.6
Fn(x)
0.4
0.2
0.0
Normal QQ Plot
5.0
4.5
Sample Quantiles
4.0
3.5
3.0
2 1 0 1 2
Theoretical Quantiles
QQ()
Q-Q
RShapiro-Wilk
8.3 48
> shapiro.test(long)
data: long
W = 0.9793, p-value = 0.01052
Kolmogorov-Smirnov
data: long
D = 0.0661, p-value = 0.4284
alternative hypothesis: two.sided
(distribution theory
)
8.3
R stats
boxplot
A <- scan()
79.98 80.04 80.02 80.04 80.03 80.03 80.04 79.97
80.05 80.03 80.02 80.00 80.02
B <- scan()
80.02 79.94 79.98 79.97 79.97 80.03 79.95 79.97
boxplot(A, B)
8.3 49
80.04
80.02
80.00
79.98
79.96
79.94
1 2
t-
> t.test(A, B)
data: A and B
t = 3.2499, df = 12.027, p-value = 0.00694
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.01385526 0.07018320
sample estimates:
mean of x mean of y
80.02077 79.97875
3 R
SPLUS t.test
F
3
:t-, t-, .
8.3 50
> var.test(A, B)
data: A and B
F = 0.5837, num df = 12, denom df = 7, p-value = 0.3938
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.1251097 2.1052687
sample estimates:
ratio of variances
0.5837405
t-
data: A and B
t = 3.4722, df = 19, p-value = 0.002551
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
0.01669058 0.06734788
sample estimates:
mean of x mean of y
80.02077 79.97875
Wilcoxon (Mann-Whitney)
(null hypothesis)
> wilcox.test(A, B)
data: A and B
W = 89, p-value = 0.007497
alternative hypothesis: true mu is not equal to 0
Warning message:
Cannot compute exact p-value with ties in: wilcox.test(A, B)
8.3 51
, (
)
qqplot Q-Q
Kolmogorov-Smirnov
Kolmogorov-Smirnov
> ks.test(A, B)
data: A and B
D = 0.5962, p-value = 0.05919
alternative hypothesis: two.sided
Warning message:
cannot compute correct p-values with ties in: ks.test(A, B)
9.1
R expression language
{expr 1 ; . . . ; expr m}
9.2
9.2.1 if
R
expr1
short-circuit&& || if
& | 1 && || 1
2
R if/else ifelseifelse(condition,
a, b)condition[i]
a[i]b[i]
1
: .
2
: TRUEFALSE.
9.2 53
(split()
help )
R for()
R whole object4
breakrepeat
next
<54>
3
lattice xyplot
4
R
, summeanapplylapply
sapplytapply
R function
R R
R
R mean(), var(),
postscript() R
expression R ()argi
10.1
t-
t-
10.2 55
Matlab y X
() qr()
n 1 y n p XX\y (X 0 X) X 0 y,
(X 0 X) X 0 Xgeneralized inverse
R lsfit() 1
qr() qr.coef()
binary operator
10.2
bslash()
%anything%
binary operator
!
()X %!% y(
)
%*% %o%
1
R<66>
10.3 56
10.3
<10> name=object
fun1
fun1
10.4 . . .
par() plot()
par() (par()<90> par()
)
. . .
10.5 57
10.5
X <- qr(X)
R Evalution frame
superassignment
<<- assign()helpSPLUS
<<- R semantics<
60>
10.6
10.6.1
(<24>)
block designblocks (b ) varieties (v
)R K v v b b replicationsblock
sizeN b v incidence matrix
E = Iv R1/2 N 0 K 1 N R1/2 = Iv A0 A, A = K 1/2 N R1/2
10.6 58
block and variety canonical contrasts
10.6.2
dimnames R
dimnames X
no.dimnames()
wrap around
> no.dimnames(X)
pattern
10.6.3
evaluation frame
2
one-panel trapezium rule
(two panel)
3 ,
R
2
that such functions, or indeed variables, are not inherited by called functions in
higher evaluation frames as they would be if they were on the search path.
3
The result is an adaptive integration process that concentrates funtion evalu-
tions in regions where the integrand is farthest from linear.
10.7 60
10.7
SPLUS R
(formal parameters)(local
variables)(free variables)
f <- function(x) {
y <- 2*x
print(x)
print(y)
print(z)
}
x y z
R
lexical scopecube,
10.7 61
sq n
(SPLUS)n
(R)cube sq
nR SPLUS SPLUS
n R cuben
## \sm{S}
S> cube(2)
Error in sq(): Object "n" not found
Dumped
S> n <- 3
S> cube(2)
[1] 18
## \R{} }
R> cube(2)
[1] 8
mutable stateR
account
account total
total
<<- total
total
total<<-
4 <<-
4
SPLUS SPLUS
10.8 62
ross$withdraw(30)
ross$balance()
robert$balance()
ross$deposit(50)
ross$balance()
ross$withdraw(500)
10.8
.First .Last
R PROFILE
Retc Rprofile.siteR
.Rprofile5
R
5
UNIX
10.9 63
.RprofileR 6 .Rprofile ()
.RData .First() R
$
Rprofile.site.Rprofile.RData .First()
.Last()()
10.9
7
plot() summary()
anova()
"data.frame"
6
Linux ~/
7
R Java(interface).,
, . .
10.9 64
methods()
> methods(class="data.frame")
plot()
"data.frame""density""factor"
methods()
> methods(plot)
> coef
function (object, ...)
UseMethod("coef")
UseMethod
methods()
> methods(coef)
[1] coef.aov* coef.Arima* coef.default* coef.listof*
[5] coef.nls* coef.summary.nls*
8
: (coef.aov), R Error: object
"coef.aov" not found.
10.9 65
> getAnywhere("coef.aov")
A single object matching coef.aov was found
It was found in the following places
registered S3 method for coef from namespace stats
namespace:stats
with value
R
R
1
R
11.1
p
X
yi = j xij + ei , ei NID(0, 2 ), i = 1, . . . , n
j=0
y = X + e
y, x, x0, x1, x2, . . . X A, B, C, . . .
1
: Later we make some rather more ambitious presumptions, namely that something
is known about generalized linear models and nonlinear regression.
11.1 67
y ~ x
y ~ 1 + x y x
y ~ 0 + x
y ~ -1 + x
y ~ x - 1 y x ()
log(y) ~ x1 + x2 y log(y) x1 x2 (
)
y ~ poly(x,2)
y ~ 1 + x + I(x^2) y x
orthogonal polynomial
y ~ X + poly(x,2) y X x
y ~ A y A
y ~ A + x y A
x
y ~ A*B
y ~ A + B + A:B
y ~ B %in% A
y ~ A/B y A Btwo factor non-
additive model
crossed classification
(nested classification)
y ~ (A + B + C)^2
y ~ A*B*C - A:B:C main effects
interactions
y ~ A * x
y ~ A/x
y ~ A/(1 + x) - 1 Ay x
A
2
2
Separate simple linear regression models of y on x within the levels of A, with
different codings. The last form produces explicit estimates of as many different intercepts and slopes
as there are levels in A.
11.1 68
y ~ A*B + Error(C) A BC
error stratasplit plot
experiment C
~ R model formula
response /
op i + -
(3
term i
1
formula expression
Y ~ M Y M
M 1 + M 2 M 1 M 2
M 1 - M 2 M 1 M 2
M 1 : M 2 M 1 M 2 tensor product
(subclasses factor)4
3
: .
4
11.1 69
M 1 %in% M 2 M 1 :M 2
M 1 * M 2 M 1 + M 2 + M 1 :M 2 .
M 1 / M 2 M 1 + M 2 %in% M1 .
M ^n M n5
I(M ) M M
I() identity function
11.1.1
(
1)
k-A
2. . . k k 1 (
)k 1
1, . . . , k orthogonal polynomial
k 6
options contrasts R
R S SHelmert
SPLUS
treatment contrast(R)
5
: All terms in M together with interactions up to order n
6
First, if the intercept is omitted in a model that contains a factor term, the first
such term is encoded into k columns giving the indicators for all the levels.
11.2 70
contrasts C
7
R
R
11.2
multiple modellm()
y x1 x2 ()
()data = production
productionproduction
11.3
lm() "lm"
"lm"
7
We have not yet considered interaction terms: these generate the products of
the columns introduced for their component terms.
11.3 71
anova(object 1 , object 2 )
coef(object) ()
coefficients(object).
deviance(object)
formula(object)
plot(object)
8
predict(object, newdata=data.frame)
data.frame
predict.gam(object,
newdata=data.frame) predict.gam()
predict()lm, glm
gam
print(object)
9
residuals(object) ( )
resid(object)
step(object)
AIC (Akaike
)
summary(object)
8
9
print()
11.4 72
11.4
aov(formula, data=data.frame) lm()
<70>
aov() multiple error strata
split plot experiments
balanced incomplete block design
strata.formula strata.formula
v + n*p*k
11.4.1
(sequence)10
11
(multistratum experiments)
Chambers &
Hastie (1992)
ANOVA tableanova()
hierarchical sequence
10
Note also that the analysis of variance table (or tables) are for a sequence of
fitted models.
11
: Hence only for orthogonal experiments will the order of inclusion be inconsequen-
tial.
11.5 73
11.5
update()
new .formula .
production
data=
update()
.
y production
add1(), drop1() step()
11.6
12
ystimulus variablex1 , x2 , . . .
12
Generalized linear modeling is a development of linear models to accommodate
both non-normal response distributions and transformations to linearity in a clean and straightforward
way.
11.6 74
y
linear predictor
= 1 x1 + 2 x2 + + p xp ,
xi i = 0 y
y
A
fY (y; , ) = exp {y() (())} + (y, )
scale parameter()A
y
y
= m(), = m1 () = `()
(estimation and inference)
McCullagh & Nelder
(1989) Dobson (1990)
11.6.1
R (gaussian), ,
(poisson), (inverse gaussian) (gamma)
quasi-likelihood
variance function
binomial logit, probit, log, cloglog
gaussian identity, log, inverse
11.6 75
family
11.6.2 glm()
R glm()
lm() family.generator
13
<74>
quasi
gaussian
13
: The only new feature is the family.generator , which is the instrument by which
the family is described. It is the name of a function that generates a list of functions and expressions
that together define and control the model and estimation process.
11.6 76
Silvey (1970)
Kalythos Aegean
Age: 20 35 45 55 70
No.: tested: 50 50 50 50 50
No.: blind: 6 17 26 37 44
logistic probit
LD5050%
y n x
y B(n, F (0 + 1 x))
LD50 = 0 /1
0
,
glm()
binary0/1
(0) (1)
11.6 77
logit
> summary(fmp)
> summary(fml)
LD50
43.66343.601
Poisson
Poisson log
Poisson
-
Poisson
Poisson
multiplier
poisson
Var[y] =
gaussian
gaussian
11.7 78
1 z1
y= +e
z2 2
1
y= +e
1 x1 + 2 x2
x1 = z2 /z1 , x2 = 1/x1 , 1 = 1/1 and 2 = 2 /1
11.7
(glm())
R
optim()nlm() nlminb()R2.2.0 SPLUS ms()
nlminb()lack-of-fit
nlm()
nlm()
14
11.7.1
SSE
> x <- c(0.02, 0.02, 0.06, 0.06, 0.11, 0.11, 0.22, 0.22, 0.56, 0.56,
1.10, 1.10)
> y <- c(76, 47, 97, 107, 123, 139, 159, 152, 191, 201, 207, 200)
> plot(x, y)
> xfit <- seq(.02, 1.1, .05)
> yfit <- 200 * xfit/(0.1 + xfit)
> lines(spline(xfit, yfit))
200 0.1
out$minimum SSEout$estimate
(SE)
295% 1.96 SE
> plot(x, y)
> xfit <- seq(.02, 1.1, .05)
> yfit <- 212.68384222 * xfit/(0.06412146 + xfit)
> lines(spline(xfit, yfit))
stats
Michaelis-Menten
11.7 80
Parameters:
Estimate Std. Error t value Pr(>|t|)
Vm 2.127e+02 6.947e+00 30.615 3.24e-11
K 6.412e-02 8.281e-03 7.743 1.57e-05
11.7.2
Maximum likelihood
> fn <- function(p)
sum( - (y*(p[1]+p[2]*x) - n*log(1+exp(p[1]+p[2]*x))
+ log(choose(n, y)) ))
11.8 81
out$minimum out$estimate
> sqrt(diag(solve(out$hessian)))
95% 1.96 SE
11.8
R
(Robust regression)
MASS lqs
MASS
rlm
(Additive models)
smooth additive function
acepack avas ace mda
bruto mars
gam mgcv
(Tree-based models)
11.8 82
tree()
plot() text()
R rpart tree
R device driver
graphics window
UNIX X11() Windows windows()
R
R
grid
grid
lattice S Trellis multi-panel
plot
12.1
()
12.1 84
12.1.1 plot()
R plot()
plot(x , y)
plot(xy) x y plot(x , y) y x
x y
()
plot(x ) x x
x
plot(f )
plot(f , y) f y f
y f
plot(df )
plot(~ expr )
plot(y ~ expr ) df y expr +
(a + b + c)
(
)y expr
12.1.2
R X
> pairs(X)
coplot a b
c ()
> coplot(a ~ b | c)
12.1 85
c a b c a
c b c
conditioning intervals c ab a
b coplot() given.values=
co.intervals()
> coplot(a ~ b | c + d)
c d a b
coplot() pairs() panel=
points()
x y panel=
coplotpanel panel.smooth()
12.1.3
tsplot(x 1, x 2, ...)
x i
1, 2, 3, . . . 1
qqnorm(x)
qqline(x)
qqplot(x, y) x
Normal order scores(
)
x y
hist(x)
hist(x, nclass=n)
hist(x, breaks=b, ...) x
nclass=
breaks= breakpoint
probability=TRUE
1
: This automatic simultaneous scaling feature is also useful when the xi s are
ordinary numeric vectors, in which case they are plotted against the numbers 1, 2, 3, . . . .
12.1 86
12.1.4
add=TRUE
()
axes=FALSE axis()
axes=TRUE
log="x"
log="y"
log="xy" x y
type= type=
type="p"
type="l"
type="b" ()
type="o"
type="h" x ( (high-
density))
type="s"
type="S"
type="n" ()
xlab=string
ylab=string x y
12.2 87
main=string
sub=string x-
12.2
()
points(x, y)
lines(x, y) plot()
type= ( points()
"p"lines() "l")
text(x, y, labels, ...) x, y labels
labels[i]
(x[i], y[i]) 1:length(x)
type="n"
text()
names
abline(a, b)
abline(h=y)
abline(v=x )
abline(lm.obj ) b a
h=y
y- v=x
x- lm.obj
2coefficients (
)
polygon(x, y, ...) (x, y)
(hatch lines)
12.2 88
(x y )
x y x y
locator()()
12.2.1
R
expression textmtextaxis
title
> help(plotmath)
> example(plotmath)
> demo(plotmath)
12.2.2 Hershey
text contour Hershey Hershey
Hershey
Hershey
Hershey cyrillic
R Hershey
> help(Hershey)
> demo(Hershey)
> help(Japanese)
> demo(Japanese)
12.3
R
locator()
locator(n, type)
n (512)
type
locator()
x y
locator()
outlying point
(postscriptlocator() )
x y (x, y)identify()
> plot(x, y)
> identify(x, y)
identify()
(
x/y )identify()
labels ()plot = FALSE
identify()
x y
12.4
R
R
(col)()
12.4.1 : par()
par()
par()
par(c("col", "lty")) (
)
12.5 91
par(col=4, lty=2) ()
par()
par()
par()
R par()
2
> oldpar <- par(col=4, lty=2)
... ...
> par(oldpar)
3
> oldpar <- par(no.readonly=TRUE)
... ...
> par(oldpar)
12.4.2
()par()
par()
12.5
R par()
2
3
12.5 92
12.5.1
R
graphical element
pch="+"
"."
pch=4 pch 025
2125
points
pch 32:255
lty=2 (
)10
2
lwd=2
lines()
col=2
(?palette)
col.axis
col.lab
col.main
col.sub x y
font=2
1 2 3 4
5 ()
12.5 93
font.axis
font.lab
font.main
font.sub x y
adj=-0.1 0 1
0.5
-0.1
10%
cex=1.5 ()
12.5.2
R axis()
axis line(
lty)tick mark() tick label(
)
lab=c(5, 7, 12) x y
las=1 0 1
2
mgp=c(3, 1, 0)
(0)
tck=0.01 tck
(0.5)x y 1
tck=0.01 mgp=c(1,-1.5,0)
xaxs="r"
yaxs="i" x y "i" () "r" ()
"r"
(S R )
12.5 94
12.5.3
R figure
plot region
mar[3]
3.0
Plot region
1.5
0.0
y
mai[2]
1.5
3.0
mai[1] x
Margin
mar mai
12.5.4
R n m
outer margin
12.5 95
oma[3]
omi[4]
mfg=c(3,2,3,2)
omi[1]
mfrow=c(3,2)
mfcol=c(3, 2)
mfrow=c(2, 4)
mfcol
mfrow
mfrow=c(3,2)
(par("cex"))
0.83
0.66
mfg=c(2, 2, 3, 2)
unequally-sized figures
fig=c(4, 9, 1, 4)/10
new=TRUE (S
)
12.6 96
oma=c(2, 0, 3, 0)
omi=c(0, 0, 0.8, 0) mar mai
mtext() outer=TRUE
oma omi
split.screen() layout()4
grid lattice
12.6
R ()
R
device driverR (draw a line,)
help(Devices)
> postscript()
PostScript
> dev.off()
4
12.6 97
()
12.6.1 PostScript
file postscript()
PostScript horizontal=FALSE
width height (
)
5PostScript
R
PostScript encapsulatedPostScript
R conformant outputonefile=FALSE
S
(EPSF )5
12.6.2
R
X11() [UNIX]
windows()
win.printer()
win.metafile() [Windows]
quartz() [MacOS X]
postscript()
pdf()
5
GSview PostScript PostScript
12.7 98
...
(
)
dev.list()
1 null de-
vice
dev.next()
dev.prev()
dev.set(which=k ) k
dev.off(k ) k
postscript
dev.copy(device, ..., which=k )
dev.print(device, ..., which=k ) k device
postscript
. . . dev.print
graphics.off()
12.7
R brush(
)6 Swayne, Cook Buja
XGobi
http://www.research.att.com/areas/stat/xgobi/
12.7 99
7
ggobiRggobi RRBioConductor
GgobiGgobiRggobihttp://www.ggobi.org/
downloads/GgobiRRggobiGgobi
$R HOME/library/Rggobi/libsGgobi
R packages
(
)
R
> library()
(boot Davison
& Hinkley (1997))
> library(boot)
> search()
( <
101>)
> help.start()
HTML Reference
13.1 101
13.1
()R R
R
R
13.2 CRAN
R
(
)R CRAN (http://CRAN.R-project.
org/ )Bioconductor (http://www.bioconductor.
org/) R
13.3
namespaces
datasets
t() R t
::
base::t
base
::: R
getAnywhere()
inter-dependent
1 R
$ R
R2
R
(R )
help.start()
HTML ()
x <- rnorm(50)
y <- rnorm(x)
x y
plot(x, y)
ls()
rm(x, y)
1
: Linux Windows
2
Windows R Windows
103
()
x <- 1:20
x = (1, 2, . . . , 20)
w <- 1 + sqrt(x)/2
x y
y x
attach(dummy)
plot(x, y)
lines(x, lrf$y)
abline(0, 1, lty=3)
(01)
104
abline(coef(fm))
detach()
plot(fitted(fm), resid(fm),
xlab="Fitted values",
ylab="Residuals",
main="Residuals vs Fitted")
heteroscedasticity
skewnesskurtosisoutlier
Michaelson Morley
morley read.table
file.show(filepath)
mm <- read.table(filepath)
mm
105
Expt Run
attach(mm)
3 ()
runs experiments
runs
detach()
rm(fm, fm0)
x x 50y
f x y cos(y)/(1 + x2 )
contour(x, y, f)
contour(x, y, f, nlevels=15, add=TRUE)
fa <- (f-t(f))/2
fa f (t() )
. . .
par(oldpar)
. . .
image(x, y, f)
image(x, y, fa)
(). . .
. . .
R
th <- seq(-pi, pi, len=100)
z <- exp(1i*th)
1i i
par(pty="s")
plot(z, type="l")
. . .
. . .
107
w <- sqrt(runif(100))*exp(2*pi*runif(100)*1i)
plot(w, xlim=c(-1,1), ylim=c(-1,1), pch="+", xlab="x", ylab="y")
lines(z)
rm(th, w, z)
q()
R R
2 R
13.4 R
UNIX Windows R R
R CMD (R
) R
UNIX TMPDIR
R
(Startup Windows-
)
--no-environR
R ENVIRON
$R HOME/etc/Renviron.site ()
.Renvironname=value (help(Startup)
)R PAPERSIZE (
/)R PRINTCMD () R LIBS (R
)
R --no-site-file
R PROFILE
$R HOME/etc/Rprofile.site
--no-init-file R
.Rprofile
13.4 R 109
.First (R .Last
) .RData
R (Memory
)R
R
--help
-h
--version
--encoding=enc stdin iconv
RHOME R shell
man R (
)
--save
--no-save R
q()
--no-environ
--no-site-file
--no-init-file
--restore
--no-restore
--no-restore-data (R
.RData)(--no-restore
--no-restore-*)
--no-restore-history (R
.RhistoryR HISTFILE )
--vanilla --no-save, --no-environ --no-site-file,
--no-init-file --no-restore
13.4 R 110
command args
BATCH R
COMPILE (UNIX)R
SHLIB shared library
INSTALL
REMOVE
build ()
check
LINK (UNIX)
Rprof R Post-process
Rdconv Rd
HTMLNroffLATEXS
Rd2dvi Rd DVI/PDF
Rd2txt Rd
Sd2Rd S Rd
config (UNIX)
R CMD
13.6 Mac OS X R 112
13.5 Windows R
Windows R(cmd.execommand.com
)R.exe Rterm.exe
)
(Rgui.exe)
Windows UNIX
home directoryWindows
R USERHOME
R
Windows (Windows XP
C:\Documents and Settings\username\My Documents )
HOMEDRIVE HOMEPATH (Windows NT/2000/XP
)
name=value
RGui.exe
--mdi
--sdi
--no-mdi MDI (
)SDI (
)Rgui
--debug Rgui Break to debugger
13.6 Mac OS X R
Mac OS X R Terminal.app R
(R.app)
13.6 Mac OS X R 113
Applications Mac OS X
Mac OS X UNIX R.framework
13.7
UNIX GNU readline R UNIX
R
UNIX GNOME
--no-readline (ESS 3 )
13.8
R
Emacs-
vi
M-i M-a ESC
RET
3
Emacs Speaks Statistics URL http://ESS.R-project.org
4
PC Alt Windows
13.9 115
13.9
C-p ()
C-n ()
C-r text text
C-p C-n
C-a
C-e
M-b
M-f
C-b
C-f
C-b C-f
text text
C-f text text
DEL ()
C-d
M-d
C-k
C-y
C-t
M-l
M-c
RET R
RET
4
t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
. . . . . . . . . . . . . . . . . . . . . . 41
CRAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
. . . . . . . . . . . . . . . . . . 78
Kolmogorov-Smirnov . . . . . . . . . . 48 . . . . . . . . . . . . . . . . . . . . . . . . . 46
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
QR . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
. . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Shapiro-Wilk . . . . . . . . . . . . . . . . . . 47 . . . . . . . . . . . . . . . . . . . . . . 73
Wilcoxon . . . . . . . . . . . . . . . . . . . . . .50 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2, 100 . . . . . . . . . . . . . . . . . . . . . . 73
. . . . . . . . . . . . . . . . . . . . . . . . . . . 54 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
. . . . . . . . . . . . . . . . . . . . . . . . . . . 56 . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
. . . . . . . . . . . . . . . . . . . . . . . . . 52 . . . . . . . . . . . . . . . . . . 46
. . . . . . . . . . . . . . . . . . . . . . 81
. . . . . . . . . . . . . . . . . . 39
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
. . . . . . . . . . . . . . . . 48 . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
. . . . . . . . . . . . . . . . . . . . . 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
. . . . . . . . . . . . . . . . . . . . . . . . . . . 62
. . . . . . . . . . . . . . . . . . . . . . . . . . . 81
. . . . . . . . . . . . . . . . . . . . . . . . . . . 98
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18, 63
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
. . . . . . . . . . . . . . . . . . . . . . . . . 55 . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
. . . . . . . . . . . . . . . . . . . . . . . . . . . 63 . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4 117
. . . . . . . . . . . . . . . . . . . . . . . . . . . 63 . . . . . . . . . . . . . . . . . . . . . . . 20, 69
. . . . . . . . . . . . . . . . . . . . . . . . . . 101
. . . . . . . . . . . . . . . . . . . . . . . . . . . 10
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .32
. . . . . . . . . . . . . . . . . . . . . . . . . 30
. . . . . . . . . . . . . . . . . . . . . . . . . . . 13
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
. . . . . . . . . . . . . . . . . . . . . . . . . 80
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 . . . . . . . . . . . . . . . . . . . . 31
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
. . . . . . . . . . . . . . . . . . . . . . . . . . . 81
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
. . . . . . . . . . . . . . . . . . . . 28
. . . . . . . . . . . . . . . . . . . . . . . . . 27
. . . . . . . . . . . . . . . . . . . . . . . . . . . 23
. . . . . . . . . . . . . . . . . . . . . . . . . . . 38
. . . . . . . . . . . . . . . . . . . 9
. . . . . . . . . . . . . . . . . . . . . . . . . . . 13
. . . . . . . . . . . . . . . . . . 30
. . . . . . . . . . . . . . . . . . . . . . . . . . . 66
. . . . . . . . . . . . . . . . . . . . . . . . . . . 90
. . . . . . . . . . . . . . . . . . . . . . 96
. . . . . . . . . . . . . . . . . . . . . . . . . . . 81
. . . . . . . . . . . . . . . . . . . . . . . . . . . 29
. . . . . . . . . . . . . . . . . . . . . . . . . . . 70
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
. . . . . . . . . . . . . . . . . . . . 52
. . . . . . . . . . . . . . . . . . . . 9, 26
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 20, 69
5
* .................................... 9 aov . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
+ ................................... 9 aperm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
-. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9 array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 as.data.frame . . . . . . . . . . . . . . . . . . . . . . . 36
.First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 as.vector . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
.Last . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 attach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
/ .................................... 9 attr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 attributes . . . . . . . . . . . . . . . . . . . . . . . . . . 18
:: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 avas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
::: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 axis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
== . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
? .................................... 4 boxplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . .49
%*% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 break . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
%o% . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 bruto . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
&& . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
& . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
c . . . . . . . . . . . . . . . . . . . . . . . . . 8, 13, 32, 35
< . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
cbind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
<<-. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
coef . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
<= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
coefficients . . . . . . . . . . . . . . . . . . . . . . . . . 71
> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
contour . . . . . . . . . . . . . . . . . . . . . . . . . . . . .86
>= . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
contrasts . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
^....................................9
coplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
~ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
cos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
abline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 crossprod . . . . . . . . . . . . . . . . . . . . . . . 25, 29
ace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 cut . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
add1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
anova . . . . . . . . . . . . . . . . . . . . . . . . . . . 71, 72 data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5 119
data.frame . . . . . . . . . . . . . . . . . . . . . . . . . 36 help.start . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
density . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 hist . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45, 85
det . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
identify . . . . . . . . . . . . . . . . . . . . . . . . . . . . .90
detach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
if . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
determinant . . . . . . . . . . . . . . . . . . . . . . . . 30
ifelse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
dev.list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
dev.next . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
is.na. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
dev.off. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
is.nan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
dev.prev . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
dev.set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 jpeg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
deviance . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
diag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 ks.test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
dim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 legend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
dotchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 length . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 16
drop1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
ecdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
edit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
eigen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 lm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
else. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .52 lme. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .81
Error . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 locator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 loess . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
exp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 log . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
lqs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
F . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 lsfit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
factor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
mars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
FALSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
max . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
fivenum . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
mean . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
for . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
min . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
formula. . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
function . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
NA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
getAnywhere . . . . . . . . . . . . . . . . . . . . . . . 64
NaN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
getS3method . . . . . . . . . . . . . . . . . . . . . . . 64
ncol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
glm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
next . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 nlm . . . . . . . . . . . . . . . . . . . . . . . . . 78, 79, 81
help.search . . . . . . . . . . . . . . . . . . . . . . . . . . 4 nlme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
5 120
nrow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 scan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
sd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
optim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
seq . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
ordered . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
shapiro.test . . . . . . . . . . . . . . . . . . . . . . . . .47
outer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
sin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 sink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
par . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 solve . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
paste . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 sort . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
pdf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
persp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 split . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
plot. . . . . . . . . . . . . . . . . . . . . . . . . . . . .71, 84 sqrt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
pmax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 stem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
pmin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 step . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71, 73
png . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 sum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 summary . . . . . . . . . . . . . . . . . . . . . . . 44, 71
polygon . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 svd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
postscript . . . . . . . . . . . . . . . . . . . . . . . . . . 96
T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
predict . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
print . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
t.test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
prod . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
table. . . . . . . . . . . . . . . . . . . . . . . . . . . .25, 32
qqline. . . . . . . . . . . . . . . . . . . . . . . . . . .46, 85 tan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
qqnorm . . . . . . . . . . . . . . . . . . . . . . . . . 46, 85 tapply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
qqplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
qr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
quartz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
TRUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 tsplot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
rbind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
read.table . . . . . . . . . . . . . . . . . . . . . . . . . . 39 unclass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
rep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
repeat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
var . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9, 21
resid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
var.test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
residuals. . . . . . . . . . . . . . . . . . . . . . . . . . . .71
vector . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
rlm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
rm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 while . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
5 121
wilcox.test . . . . . . . . . . . . . . . . . . . . . . . . . . 50
windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
X11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
6
D. M. Bates and D. G. Watts (1988), Nonlinear Regression Analysis and Its Applica-
tions. John Wiley & Sons, New York.
Richard A. Becker, John M. Chambers and Allan R. Wilks (1988), The New S Lan-
guage. Chapman & Hall, New York. This book is often called the Blue Book .
John M. Chambers and Trevor J. Hastie eds. (1992), Statistical Models in S. Chapman
& Hall, New York. This is also called the White Book .
John M. Chambers (1998) Programming with Data. Springer, New York. This is also
called the Green Book .
A. C. Davison and D. V. Hinkley (1997), Bootstrap Methods and Their Applications,
Cambridge University Press.
Annette J. Dobson (1990), An Introduction to Generalized Linear Models, Chapman
and Hall, London.
Peter McCullagh and John A. Nelder (1989), Generalized Linear Models. Second edi-
tion, Chapman and Hall, London.
John A. Rice (1995), Mathematical Statistics and Data Analysis. Second edition.
Duxbury Press, Belmont, CA.
S. D. Silvey (1970), Statistical Inference. Penguin, London.
123