You are on page 1of 42

R

R frequently asked questions

http://www.r-project.org

153

This document is generated from LATEXsources compiled with ctex v0.7d


in a Windows platform . The used packages are CJK listingsgraphicx and so on.

R R introR dataR admin


contributed documents Capital Of Statistics
R R

R CRAN Task Views


R Packages
R
R
38 R
1
July 24, 2008

abel,cran,rtist,Xie Yihui,zhangv . . .

1 sunbjt<at>gmail.com

1. R
R Ross Ihaka
Robert Gentleman R Becker, Chambers & Wilks S Sussman Scheme

R S
2. R

R http://cran.r-project.org/mirrors.html UC
Berkeley R LinuxMacOS XWindows Windows
Windows (95 and later) base R-x.x.x-win32.exe
3. R R

R (Robert Gentleman Ross Ihaka) S


S
4. CRAN
CRAN C omprehensive R Archive N etwork R

5. R
R http://cran.r-project.org/other-docs.
html bbs R

6. R R-intro
R-intro R R

R-intro
7. R

R R
Modern Applied Statistics with SVenables and Ripley
The New S Language: A Programming Environment for Data Analysis and Graphics
Richard A. BeckerJohn M. ChambersAllan R.Wilks
A Handbook of Statistical Analysis Using RBrian S. EverittTorsten Hothorn
Data Analysis and Graphics using RMaindonald and Braun
Introductory Statistics with RDalgaard
8. R

R
R
9. R

100 100
x < rnorm ( 1 0 0 , mean = 5 , sd = 0 . 1 )

mean ( x )
sd ( x )

summary ( x )

demo() R
demo ( g r a p h i c s )
10. R

R GNU General Public License (GPL)

11. R 50% CPU

Windows CPU CPU R


2 CPU
CPU 50%
12. R

LATEX R citation() BibTEX

c i t a t i o n ( package = package )

13.
R ?topic help(topic) topic
help.search(topic)

apropos(tab)
tab
R Site Searchhttp://finzi.psych.upenn.edu/search.
html R RSiteSearch()
14. R

R R CMD Rterm
r maxmems i z e =1Gb

RHOME/bin 2
r g u i maxmems i z e =1Gb

R memory.limit R
R 32Mb 3Gb Windows

2Gb R 32Mb 2Gb


15. help.search()

Java Java Javascript


16. R

17. R Tab completion

2.5.0 R Tab R
Tab
18.

rm()
1

rm( l i s t = l s ( a l l = TRUE) )
19.
options(digits = ) digits 1 22 7options

(prompt) (show.error.messages)
20.

system() shell.exec() :
1

go

to

the

cran

system ( p a s t e ( "C:/Program Files/Internet Explorer/iexplore.exe" ,


2

Rterm

cran.r-project.org ) , w a i t = FALSE)

invoke

the

notepad

system ( "notepad" )

s h e l l . e x e c ( "C:/WINDOWS/clock" )
21. Windows R packages

R library library
update.packages() R R update.packages()
22. packages

remove . p a c k a g e s ( c ( "pkg1" , "pkg2" ) ,


l i b = f i l e . path ( "path" , "to" , "library" ) )

23. R

Windows XP R
C: \ Documents and S e t t i n g s \ username

getwd() R (Working Directory) setwd()


24.

save.image() R working space.RData


save(..., file = ) R
25. R

R
3
26. library()

R
d e t a c h ( "package:pkg" )

27. Library Package

R Package LibraryLibrary
Package Package Library
Windows *.zip
28. Package
3R

UnixMacWindows

search()
1

. p a c k a g e s ( a l l . a v a i l a b l e = TRUE)

R R Package
R

stats

grid
R

graphics
grDevices
utils
datasets
methods
base

29. R
R datasets 100 data()

dim ( data ( ) $ r e s u l t s )
data ( ) $ r e s u l t s [ , 4 ]
30. R
RS class

1
2
3
4
5
6
7

charactor
numeric
integer
logical
complex
list
factor

TRUE=TFALSE=F
a
S

16

RS
Everything in S is an object;
Every object is S has a class.
31. data frame
6

data frame

matrix-like
32.

R
dist

Generic Function
methods() 4
1

summary

It

is

generic

methods ( summary )

summary . lm

you

# maybe

funciton

list

of

want

the
to

S3

know

methods
the

linear

models s

summary

*.tar.gz R-2.5.1.tar.gz
33.

head() tail()
1

head (CO2)

car some
34. R

lmglm y model y model


model + : + :
0 a + b + a : b0 (a + b + c) 2 (a + b + c) (a + b + c) abc
(a + b + c) 2 a : b 0 a + b + c + b : c + a : c0
0 log(y) a + log(x)0
. update
1

fm < aov ( Speed Run + Expt )


fm0 < update ( fm , . . Run)

H lattice |
35. R

1 e10 == 10000000000
2

1 . 2 e4 == 0 . 0 0 0 1 2
4

getAnywhere()

36. R

foreign Minitab, S, SAS, SPSS, Stata, Systat, dBase


37. R Excel

Excel Excel
Excel
1. Excel csv(Comma Separated Values) read.csv()
2. RODBC odbcConnectExcel() xls
l i b r a r y (RODBC)
z < odbcConnectExcel ( "rexceltest.xls" )

dd < s q l F e t c h ( z , "Sheet1" )
close (z)

R Data Import/Export
3. xlsReadWrite read.xls
38. R

sink()
data (CO2)
2

s i n k ( "CO2.txt" )
CO2

sink ()

go

to

your

work

directory ,

you

will

get

CO2 . t x t

39. R
R capture.output() R
glmout < c a p t u r e . output ( example ( glm ) )
2

glmout [ 1 : 5 ]

Go to LATEX!
40. R

data < r e a d . t a b l e ( "clipboard" )


2

w r i t e . t a b l e ( "clipboard" )

41. (factor)

f
a s . numeric ( a s . c h a r a c t e r ( f ) )
2

or

a s . numeric ( l e v e l s ( f ) ) [ a s . i n t e g e r ( f ) ]
42. R

edit() fix()
1

data < data . frame ( )


edit (x) ;

fix (x)

43. source()

print() source(file,echo = TRUE) R


sink() source(file,echo = TRUE) sink

44. R TEX

Hmisc latex() xtable xtable()


a < matrix ( 1 : 6 , nr =1)
2

require ( xtable )

colnames ( a ) < p a s t e ( "col" , 1 : 6 )


xtable (a)
xtable() HTML R

wordpowerpoint
LATEX quantreg latex.table()
45.

R
1

d : \ \R 2 . 4 . 1 \ \ l i b r a r y \\ x g o b i \\ s c r i p t s \\ x g o b i . bat
d : /R 2 . 4 . 1 / l i b r a r y / x g o b i / s c r i p t s / x g o b i . bat

file.choose() Windows
choose.dir() Windows ,
46. R

SQL R SQL
OracleMicrosoft SQL ServerIBM DB2 GNU
General Public License (GPL) MySQL

MySQL RODBC
ODBC R

RMySQL

l i b r a r y (RODBC)
ch < odbcConnect ( "stocksDSN" , u i d = "myuser" ,pwd = "mypassword" )

s t o c k s < s qlQ ue r y ( ch , "select from quotes" )


o d bc C l os e ( ch )

Windows Microsoft SQL ServerAccessOracleMySQLPostgreSQL


Linux MySQLOraclePostgreSQLSQLite R-data

47.

R NAnot available RS NA 6
x < NA
x > 3

class (x)

x == NA

is.na()
x [ ! i s . na ( x ) ]

48.

eval() parse() parse() expression


eval()
x < 1 : 1 0

a < "print(x)"
class (a)

eval ( parse ( text = a ))


49.

append()
5
6R

DBI
TRUEFALSENA

10

x < 1 : 5
2

( f o o < c ( x [ 1 ] , 0 , x [ 2 : 5 ] ) )

expected

result

append ( x , 0 , a f t e r = 1 )
50. ()

subset(select = )
1

x < data . frame ( matrix ( 1 : 3 0 , nrow = 5 , byrow = T) )


dim ( x )

print (x)
new . x1 < x[ c ( 1 , 4 ) , ]

#row

new . x2 < x [ , c [ 2 , 3 ] ]

#col

new . x1 ; new . x2

subset
i S < i r i s $ S p e c i e s == "setosa"
2

i r i s [ iS , c ( 1 , 3 ) ]
s u b s e t ( i r i s , s e l e c t = c ( S e p a l . Length , P e t a l . Length ) , S p e c i e s == "setosa" )
51.

a1 < data . frame (num = 1 : 8 , l i b = l e t t e r s [ 1 : 8 ] )


a2 < a1

a2 [ [ 3 , 1 ] ] < 2 > a2 [ [ 8 , 2 ] ]
any ( a1 !=a2 )

a l l ( a1

==

a2 )

any()
a1 !=a2

TRUE any() TRUE identical()


1

i n d e n t i c a l ( a1 , a2 )

which ( a1 !=a2 , a r r . i n d = TRUE)


arr.ind array indices
52.

unique unique

11

x < c ( 9 : 2 0 , 1 : 5 , 3 : 7 , 0 : 8 )

unique ( x )

( xu < x [ ! d u p l i c a t e d ( x ) ] )
#

is

more

efficient

duplicated
53. array

aperm
1

< a r r a y ( 1 : 2 4 , 2 : 4 )

xt < aperm ( x , c ( 2 , 1 , 3 ) )
3

dim ( x )

dim ( xt )

54. list
R NULL
1

l s t < l i s t ( "a"= l i s t ( "b"=1,"c"=2) ,"b"= l i s t ( "d"=3,"e"=4))


l s t [ [ "a" ] ] [ "b" ] < NULL

or

lst

$ a $ b <

NULL

lst
55. ()

apply()
1

vec =1:20
mat=matrix ( vec , n c o l =4)

vec
cumsum ( vec )

mat
apply ( mat , 2 , cumsum )

apply ( mat , 1 , cumsum )


56. R

(Regular Expression)
*.R source(*.R) #

i f (FALSE) {
something passby

}
57. (data frame)

transform() ?transform
12

58.
pmax() pmin()
1

x < 1 : 1 0

y < r e v ( x )

pmax ( x , y )

pmin ( x , y )

59.

tapply()
n < 1 7 ; f a c < f a c t o r ( r e p ( 1 : 3 , l e n = n ) , l e v e l s = 1 : 5 )
2

table ( fac )
t a p p l y ( 1 : n , f a c , sum )

t a p p l y ( 1 : n , f a c , mean )
##

or

reverse

list

t o < l i s t ( a = 1 , b = 1 , c = 2 , d = 1 )
t a p p l y ( t o , u n l i s t ( t o ) , names )
tapply() meanvarsd

aggregate() tapply() 7
1

a t t a c h ( warpbreaks )
t a p p l y ( breaks , l i s t ( wool , t e n s i o n ) , mean )

a g g r e g a t e ( breaks , l i s t ( wool , t e n s i o n ) , mean )


##

from

the

help

a g g r e g a t e ( s t a t e . x77 ,
l i s t ( Region = s t a t e . r e g i o n ,
Cold = s t a t e . x77 [ , "Frost" ] > 1 3 0 ) ,

mean )
60.
sapply(dataframe, is.numeric)
61.

sample()
sample(n)
sample(x)
sample(x, replace = T)
sample(x,n)
sample(x,n, replace = T)
sample(x,n, replace = T ,prob = p)

1, . . . , n
x, length(x) > 1

x n
x n
p x n

13

n < 1000
2

x < sample ( c ( 1 ,1) , n , r e p l a c e=T)


p l o t ( cumsum ( x ) , type="l" ,

main="Cumulated sums of Bernoulli variables" )

17
rnorm ( 1 0 0 , mean=0, sd =1)
62.

merge(x, y ,by.x = ,by.y = ,all = )


63.

scale
1

x < c ( rnorm ( 1 0 0 ) , 2 rnorm ( 3 0 ) )


m < s c a l e ( x , s c a l e = F)

only

centering

n < s c a l e ( x , c e n t e r = F)

only

scaling

64. fivenum summary

> fivenum ( c ( 1 , 4 , 6 , 1 7 , 5 0 , 5 1 , 7 0 , 1 0 0 ) )
[1]

5.0

33.5

60.5 100.0

> quantile ( c (1 ,4 ,6 ,17 ,50 ,51 ,70 ,100))


0%

1.0

1.00

25%
5.50

50%

75%

100%

33.50

55.75 100.00

8 14 , 34

1
1
1 + (length(x) 1),
4
4
3
3
1 + (length(x) 1),
4
4

c (1 ,4 ,6 ,17 ,50 ,51 ,70 ,100)

1+
8 summary()

21
7
= 2.75, 1 +
= 6.25
4
4

14


4 + (6 4) 0.75 = 5.5, 51 + (70 51) 0.25 = 55.75

fivenum() NL NU
length(x) lenght(x)
NL , NU

65.
R integrate
1

i n t e g r a t e ( dnorm , 1.96 , 1 . 9 6 )
i n t e g r a t e ( dnorm , I n f , I n f )

## a

slowly convergent

integral

i n t e g r a n d < f u n c t i o n ( x ) {1 / ( ( x+1) s q r t ( x ) ) }
5

i n t e g r a t e ( i n t e g r a n d , l o w e r = 0 , upper = I n f )
66.

t() R x integer t(t(x))


1

x < 1 : 1 0

t (x)

class ( t (x))

t ( t (x)) ;

class (x)

class ( t ( t (x )))

x%%x

xT x xxT %o% outer() crossprod()


1

XT. y < c r o s s p r o d (X, y )

X T Y crossprod() 9 outer()

p
sin x2 + y 2
10 p
x2 + y 2
R
1

f < f u n c t i o n ( x , y ) { r < s q r t ( x2+y 2 ) ; 10 s i n ( r ) / r }


z < o u t e r ( x , y , f )
9

15

67. R

complex()
x < 1 + 1 i
2

Mod( x )

# x

<

complex (1 ,1)

; Conj ( x )

68.

diag() Z Z

69.

1 2
2
1 1

eigen A =
2 1 2 B = ( 2A ) + E
2 2 1
A < matrix ( c ( 1 ,2 ,2 ,2 , 1 , 2 ,2 , 2 , 1) ,3 ,3)
2

m < s o l v e ( 0 . 5 A) + d i a g ( c ( 1 , 1 , 1 ) )
e i g e n (m)

solve()
1

a%%x = b

x
70.

lower.tri() upper.tri()
1

Rmat < matrix ( 1 : 1 6 , 4 , 4 )


Rmat [ l o w e r . t r i (Rmat ) ] < 0

Rmat
71.
x(1/3) R sqrt() R

"" ( x , 1/ 3 )

R
R

+,-,*,/,,%%,%/%
>, <, >=, <=, ==, ! =

72. ()

16

apply() rowMeans() colMeans()

m < 1000

n < 3000

A < matrix ( 1 :mn ,m , n )


3

system . time ( B1 < matrix ( apply (A, 2 , mean ) , m, n , by=T) )


system . time ( B2 < matrix ( colMeans (A) , m, n , by=T) )
73.

choose() nk combn() factorial()


Cnm =

!n
!m!(n m)

74. R

D()
f 1 < e x p r e s s i o n ( s i n ( x ) x )
2

f 2 < e x p r e s s i o n ( x 2 y + y 2 )
D( f , "x" )
75.

rnorm(n , mean , sd) n mean sd

R
20
R-intro Probability distributions

h e l p . s e a r c h ( "distribution" )
0.4

0.3

XN (3, 1)

pnorm

0.1

pnorm ( 5 , 3 , 1 ) pnorm ( 2 , 3 , 1 )

P(2<x<5)

0.8185946
0.0

0.2

Density

P (2 6 X 6 5)

76.
17

uniroot() uniroot

f <f u n c t i o n ( x ) x 3 2 x 1

uniroot ( f , c (0 ,2))

optimize()
f < f u n c t i o n ( x ) x 2 + 2x + 1
o p t i m i z e ( f , c ( 2 ,2))

77. R
R Unix R tolower() toupper() casefold()

x < "MiXeD cAsE 123"


2

c h a r t r ( "iXs" , "why" , x )
c h a r t r ( "a-cX" , "D-Fw" , x )

tolower (x)
toupper ( x )
78. R

paste()
1

f o r ( var i n l e t t e r s [ 1 : 6 ] ) {
x < var

w r i t e . t a b l e ( x , p a s t e ( "FOO " , var , ".txt" , s e p = "" ) )


}

# You

will

get

FOO

a . txt

.. .

79. R Regular Expressions

R extended regular expressions grep(extended = TRUE)


basic regular expressions grep(extended = FALSE)Perl-like regular expressions
grep(perl = TRUE) . \. .
g r e p ( "J." , month . abb )

help(regex)
80.

substr()
18

s u b s t r ( "abcdef" , 2 , 4 )

s u b s t r i n g ( "abcdef" , 1 : 6 , 1 : 6 )


81.

nchar
nchar ( month . name [ 9 ] )

82.

as.Date() as.POSIXct() Date


Date
d1 < c ( "06/29/07" ) ;

d2 < c ( "07/02/07" )

D1 < a s . Date ( d1 , "%m/%d/%y" )


D2 < a s . Date ( d2 , "%m/%d/%y" )

D1 + 2

D1 D2

d i f f t i m e (D1 , D2 , u n i t s = "days" )

83. , 22 2007

format()
format ( ( Sys . Date ( ) , format="%A, %d %B %Y" )

format help(strptime) details

84.

par(mfrow = c(2,2)) par(mfcol = c(2,2))


layout
split.screen()

layout() Statistics with R

19

l a y o u t ( matrix ( c ( 1 , 1 , 1 ,
2, 3, 4,
2 , 3 , 4 ) , nr = 3 , byrow = T) )

h i s t ( rnorm ( 2 5 ) , c o l = "VioletRed" )
5

h i s t ( rnorm ( 2 5 ) , c o l = "VioletRed" )
h i s t ( rnorm ( 2 5 ) , c o l = "VioletRed" )

h i s t ( rnorm ( 2 5 ) , c o l = "VioletRed" )
85.

par(mar = c(bottom, left, top, right))bottom, left, top, right


bottom, left, top, right c(5, 4, 4, 2) + 0.1 par(mai =
c(bottom, left, top, right))
86. pch
pch plotting character pch

0 : 25 26
pch
#, %, , |, +, , ., o, O21 : 25
points
bg=
1

11 13 15 17 19 21 23 25

10 12 14 16 18 20 22 24

op < par ( bg = "light blue" )


x < s e q ( 0 , 2 pi , l e n =51)

p l o t ( x , s i n ( x ) , type = "o" , bg=par ( "bg" ) )


p o i n t s ( x , s i n ( x ) , pch = 2 1 , cex =1.5 , bg="red" )
87.

abline()y h=x v= a=
b=
R High levelLow level Interactive

88.

dfunction(x)
20

x=s e q ( 3 , 3 , . 0 5 )
p l o t ( x , dnorm ( x ) , type="l" )

l i n e s ( x , dt ( x , 1 ) , c o l = "red" )

dfunction(x) function R-intro Probability distributions


help.search(distribution) 17
R

beta

beta

shape1(),shape2()

binom

size(n),prob(p)

chisq

df

unif

min(a),max(b)

min = 0, max = 1

exp

rate

rate = 1

df1(r1 ),df2(r2 )

gamma

shape(),scale()

hyper

m = N1 , n = N2 , k = n

norm

mean(),sd()

pois

lamda()

df

weibull

shape(),scale()

scale = 1
mean = 0, sd = 1

scale = 1

89.

legendhelp(legend)
1

with ( i r i s , p l o t ( S e p a l . Length , S e p a l . Width ,

l e g e n d ( 6 . 1 , 4 . 4 , c ( "setosa" , "versicolor" , "virginica" ) ,

pch=a s . numeric ( S p e c i e s ) , cex = 1 . 2 ) )


cex =1.5 , pch =1:3)
90.

pie()
bar chartdot chart
91.

stem
stem ( f a i t h f u l $ e r u p t i o n s )
92.

21

R par(new = TRUE) (hight-level plot)

GDP (UR)
1

y e a r < 1 9 9 5 : 2 0 0 5
x1 < data . frame ( y e a r , GDP = s o r t ( rnorm ( 1 1 , 1 0 0 0 , 1 0 0 ) ) )

x2 < data . frame ( y e a r , UR = rnorm ( 1 1 , 5 , 1 ) )


par ( mar = c ( 5 , 4 , 4 , 6 ) + 0 . 1 )

p l o t ( x1 , a x e s = FALSE, type="l" )
a x i s ( 1 , a t = year , l a b e l = y e a r ) ; a x i s ( 2 )

par ( new = T, mar = c ( 1 0 , 4 , 1 0 , 6 ) + 0 . 1 )


p l o t ( x2 , a x e s = FALSE, x l a b = "" , y l a b = "" , c o l = "red" , type= "b" )

mtext ( "UR(%)" , 4 , 3 , c o l="red" )


a x i s ( 4 , c o l ="red" , c o l . a x i s

= "red" )

plotrix twoord.plot()
twoord . p l o t ( 2 : 1 0 , s e q ( 3 , 7 , by=0.5)+ rnorm ( 9 ) ,
2

1 : 1 5 , r e v ( 6 0 : 7 4 ) + rnorm ( 1 5 ) , x l a b="Sequence" ,
y l a b="Ascending values" , r y l a b="Descending values" ,

main="Test of twoord.plot" )

93.

grid()
plot (1:3)
2

g r i d (NA, 5 , lwd = 2 )

grid

only

in

y d i r e c t i o n

94.

strwrap
p l o t ( 0 , main = p a s t e ( s t r w r a p ( "This is a really long title that
2

i can not type it properly" , width = 50 ) ,


c o l l a p s e = "\n" ) )
95.

dev.list() dev.cur()
dev.set()dev.off()
96. y
22

? par

see

las

p l o t ( 0 , 0 , xaxt="n" , type="n" , ylim=c ( 0 , 1 0 0 ) , l a s =1 )


3

mtext ( "35" , s i d e =2, a t =35 , l i n e =1, l a s =1)


97.
R ?Devices
R

x11

Windows

windows

ps

postscript

pdf

pdf
png

EX
png

jpeg

jpeg

bmp

bmp

pictex

xfig
win.metafile
a

LAT

XFIG
emf

Windows

postscript() ps
98.
R stars
1

s t a r s ( s t a t e . x77 [ , c ( 7 , 4 , 6 , 2 , 5 , 3 ) ] , f u l l = FALSE,
key . l o c = c ( 1 0 , 2 ) )

full = FALSE key.loc

99. R 8

col R 8
palette ()
2

b a r p l o t ( rnorm ( 1 5 , 10 , 3 ) , c o l = 1 : 1 5 )

b a r p l o t ( rnorm ( 1 5 , 10 , 3 ) , c o l = 1 : 1 5 )

p a l e t t e ( rainbow ( 1 5 ) )
p a l e t t e ( "default" )

R 657
23

colors ()

R 502
rgb()
100.

col barplot() (color


sets)
R

rainbow()
heat.colors()
terrain.colors()
topo.colors()
cm.colors()
gay()grey()
1

x < 1 : 1 0

)
( )
( )
( )
( )
( )
(

; names ( x ) < l e t t e r s [ 1 : 1 0 ]

barplot (x , c o l = rev ( heat . c o l o r s ( 1 0 ) ) )


3

b a r p l o t ( x , c o l = gray ( ( 1 : 1 0 ) / 1 0 ) ) ;
101. R RGB

col2rgb()
1

w r i t e . t a b l e ( t ( c o l 2 r g b ( rainbow ( 7 ) ) / 2 5 5 ) , s e p = "," )
102.
Windows savePlot()

windows ( width = , h e i g h t = )

pdf() ,postscript() , png() ,jpeg() ,pictex()



1

##

##

start

PDF

file

pdf ( "picture.pdf" , h e i g h t =4, width =6)


your

drawing

dev . o f f ( )

###

commands
close

the

here
PDF

file

24

dev . copy ( d e v i c e , f i l e ="" , h e i g h t , width )

103.

two

dimensions

n < 100
3

x < cumsum ( rnorm ( n ) )


y < cumsum ( rnorm ( n ) )

p l o t ( x , y , type = l )
104.

curve(expr, from , to, add = T)


spline(x , y , n= )
1

x < 1 : 5
y < c ( 1 , 3 , 4 , 2 . 5 , 2 )

plot (x , y)
sp < s p l i n e ( x , y , n = 5 0 )

l i n e s ( sp )
105. (lattice)

lattice S-plus Trellis R


library ( lattice )
h i s t o g r a m ( h e i g h t | v o i c e . part , data = s i n g e r )

lattice
lattice

xyplot(yx)

Cleveland ()
y x
x y

dotplot(yx)
barchart(yx)
stripplot(yx)
bwplot(yx)
histogram(x)

106.

25

persp() contour() 15
outer()
107.

image() filled.contour()
x < y < s e q ( 10 , 1 0 , l e n g t h =50)
2

f < f u n c t i o n ( x , y ) {
r < s q r t ( x 2 + y 2 )
10 s i n ( r ) / r

}
6

z < o u t e r ( x , y , f )
image ( x , y , z )

f i l l e d . contour ( x , y , z )
108.

R R
x < 1 : 1 0
2

y < r u n i f ( 1 0 )
symbols ( x , y , c i r c l e s = y/2 , i n c h e s = F , bg = x )
109. QQ

apply() R
1

t a b l e < data . frame ( x1 = rnorm ( 1 0 0 ) , x2 = rnorm ( 1 0 0 , 1 , 1 ) )


par ( ask=TRUE)

wait

for

changing

r e s u l t s = apply ( t a b l e , 2 , qqnorm )
par ( ask=FALSE)
110.

par()
x < rnorm ( 1 0 0 )
2

hist (x)
op < par ( f i g=c ( . 0 2 , . 5 , . 5 , . 9 8 ) , new=TRUE)

boxplot (x)
111. R

?plotmath LATEX

26

x < 1 : 1 0
2

p l o t ( x , type = "n" )

t e x t ( 3 , 2 , e x p r e s s i o n ( p a s t e ( "Temperature (" , d e g r e e , "C) in 2003" ) ) )


t e x t ( 4 , 4 , e x p r e s s i o n ( bar ( x ) == sum ( f r a c ( x [ i ] , n ) , i ==1, n ) ) )

t e x t ( 6 , 6 , e x p r e s s i o n ( hat ( b e t a ) == (X t X) { . 1 } X t y ) )
t e x t ( 8 , 8 , e x p r e s s i o n ( z [ i ] == s q r t ( x [ i ] 2 + y [ i ] 2 ) ) )
112. bar

barplot() rect()
1

x < 1 : 1 0

; names ( x ) < l e t t e r s [ 1 : 1 0 ]

b < b a r p l o t ( x , c o l = r e v ( h e a t . c o l o r s ( 1 0 ) ) )
3

t e x t ( b , x , l a b e l s = x , pos = 3 )
113.

y
x
( )2 + ( )2 = 1 = x = a sin , y = b cos , 0 < < 2
a
b
1

t < s e q ( 0 , 2 pi , l e n g t h = 1 0 0 )
x < s i n ( t )

a =1

y < 2 c o s ( t )

b =2

p l o t ( x , y , type = l )
114. word R

epspdfpngjpgtiff word
eps

115.

FBasics
skewness ( )
2

kurtosis ()

116.
table() table(x) x table(x,y)

27

x < with ( a i r q u a l i t y , t a b l e ( c u t (Temp , q u a n t i l e (Temp ) ) , Month ) )


2

prop . t a b l e ( x , 1 )
117.

yi = + xi + i


lm()
lm . s w i s s < lm ( F e r t i l i t y . , data = s w i s s )
lm()
coefficients
residuals
fitted.values
. . . . . .
:
1

names ( lm . s w i s s )
summary() anova()

summary ( lm . s w i s s )

the

same

as

summary . lm ( )

anova ( lm . s w i s s )

R-intro Statistical models in R


biglm biglm()

118.

update()
summary ( f 0 < lm ( F e r t i l i t y . , data = s w i s s ) )
2

f 1 < update ( f0 , . . Examination )


summary ( f 1 )
119.

R step() AIC AIC

u t i l s : : example ( lm )
s t e p ( lm . D9)
28

step both,forward,backward backward


add1drop1
120. R (Quantile Regression)

quantreg quantregForest
data ( e n g e l )
2

t a u s < c ( . 1 5 , . 2 5 , . 5 0 , . 7 5 , . 9 5 , . 9 9 )
r q s < a s . l i s t ( t a u s )

f o r ( i in seq ( along = taus ) ) {


r q s [ [ i ] ] < rq ( l o g 1 0 ( f o o d e x p ) l o g 1 0 ( income ) ,
tau = t a u s [ i ] , data = e n g e l )

l i n e s ( l o g 1 0 ( e n g e l $ income ) , f i t t e d ( r q s [ [ i ] ] ) , c o l = i +1) }
8

l e g e n d ( "bottomright" , p a s t e ( "tau = " , t a u s ) , i n s e t = . 0 4 ,


c o l = 2 : ( l e n g t h ( t a u s )+1) , l t y =1)
121.

t.test()
1

x < rnorm ( 1 0 0 )
t . test (x)
122.
K (kmeans() )
x < r b i n d ( matrix ( rnorm ( 1 0 0 , sd = 0 . 3 ) , n c o l = 2 ) ,

matrix ( rnorm ( 1 0 0 , mean = 1 , sd = 0 . 3 ) , n c o l = 2 ) )


c l < kmeans ( x , 2 , 2 0 )

p l o t ( x , c o l = c l $ c l u s t e r , pch =3, lwd=1)


p o i n t s ( c l $ c e n t e r s , c o l = 1 : 2 , pch = 7 , lwd=3)

segments ( x [ c l $ c l u s t e r = = 1 , ] [ , 1 ] , x [ c l $ c l u s t e r = = 1 , ] [ , 2 ] ,
cl $ centers [1 ,1] , cl $ centers [1 ,2])

segments ( x [ c l $ c l u s t e r = = 2 , ] [ , 1 ] , x [ c l $ c l u s t e r = = 2 , ] [ , 2 ] ,
cl $ centers [2 ,1] , cl $ centers [2 ,2] ,

10

c o l =2)

(hclust() )
n < s e q ( 1 , 5 0 , by = 4 )
2

( x < USArrests [ n , ] )
hc1 < h c l u s t ( d i s t ( x ) ,

print ()

method = "complete" )

hc2 < h c l u s t ( d i s t ( s c a l e ( x ) ) , method = "complete" )


29

hc3 < h c l u s t ( d i s t ( x ) ,
6

method = "ave" )

l a y o u t ( matrix ( c ( 1 , 1 , 2 , 3 ) , nrow = 2 , byrow = T) )


p l o t ( hc1 ) ; p l o t ( hc2 ) ; p l o t ( hc3 )

cutree()
1

c u t r e e ( hc , k = 1 : 3 )

cluster
1

library ( cluster )
c l u s p l o t ( x , pam( x , 2 ) $ c l u s t e r i n g )
123.
stats princomp
( pc . c r < princomp ( USArrests , c o r = TRUE) )

p l o t ( pc . c r , type = "lines"
)

or

or

barplot

screeplot

l o a d i n g s ( pc . c r )
princomp() cor = TRUE

loadings() screeplot()
124.

R factanal()
example ( f a c t a n a l )
125.

shapiro.test() ks.test()(Kolmogorov-Smirnov ) jarque.bera.test() (


tseries ) normtest fBasics

126. t

t.test() paired
1

require ( stats )
##

Student s

paired

ttest

t . t e s t ( e x t r a group , data = s l e e p , p a i r e d = TRUE)

30

SPSS

a p r o po s ( "test" )


bartlett.test
chisq.test
fisher.test
kruskal.test
pairwise.t.test
var.test

2
Fisher
Kruskal-Wallis

binom.test
cor.test
friedman.test
mcnemar.test
PP.test
wilcox.test

extra

group

0.7

-0.6

4.6

3.4

Friedman
McNemar
Phillips-Perron
Wilcoxon

127. R

sem
128.

I()
1

lm ( y x + I ( x 2 ) + I ( x 3 ) )
129. ANOVA

aov()

aov(x a)
aov(x a + b)
aov(x a + b +a:b)
aov(x a*b)

130.

0
1

r e s u l t < lm ( smokes 0 + male + f e m a l e , data=smokerdata )


131.

confintglm nls MASS confint.glm confint.nls


31

f i t < lm ( 1 0 0 /mpg d i s p + hp + wt + am, data=mtcars )


confint ( f i t )

c o n f i n t ( f i t , "wt" )
132.

MASS lm.ridge()
1

data ( l o n g l e y )

not

the

same

as

the

S PLUS

dataset

names ( l o n g l e y ) [ 1 ] < "y"


3

lm . r i d g e ( y . , l o n g l e y )
p l o t ( lm . r i d g e ( y . , l o n g l e y ,
lambda = s e q ( 0 , 0 . 1 , 0 . 0 0 1 ) ) )

s e l e c t ( lm . r i d g e ( y . , l o n g l e y ,
lambda = s e q ( 0 , 0 . 1 , 0 . 0 0 0 1 ) ) )

133. logistic
logistic 01
glm()

Gaussian

E(y) = x
exp (xT )
1+exp (xT )
T

Binomial

E(y) =

Poission

E(y) = exp (x )

Logistic probit

a Normal

f i t 1 < glm ( formula , f a m i l y = g a u s s i a n , data )

f i t 1 < lm ( formula ,

data )

134.

yi = 0 + 1 xi + 2 x2i + . . . + k xki , i = 1, 2, . . . , n,

k x, x2 , . . . , xk
R poly()
1

( z < p o l y ( 1 : 1 0 , 3 ) )

32

135.

hat(),hatvalues()
136. D-W
car durbin.watson lmtest dwtest
1

h e l p . s e a r c h ( "Durbin-Watson" )
137. Spearman kendall
cor() Person method Kendall Spearman

c o r ( l o n g l e y , method = "spearman" )

Pearson

Kendall
Spearman

138. Decision Tree

Tree-based model
Modern Applied Statistics With S rpart
1

library ( rpart )
set . seed (123)

cpus . rp < r p a r t ( l o g 1 0 ( p e r f ) . , cpus [ , 2 : 8 ] , cp = 1 e 3)


p l o t ( cpus . rp , uniform = T)

t e x t ( cpus . rp , d i g i t s = 3 )
139.

t 0 2 q
Xt =

q
X

j tj

p
Xt =

p
X

i Xti + t

ARM A(p, q)
Xt =

p
X

i Xti +

q
X
0

33

j tj

arma arima R arima(x, order = c(0, 0, 0), seasonal =


list(order = c(0, 0, 0))
require ( graphics )

( f i t 1 < arima ( p r e s i d e n t s , c ( 1 , 0 , 0 ) ) )
tsdiag ( f i t 1 )

140. box-cox
MASS
1

boxcox ( )

141. Breusch-Pagan
lmtest bptest() car ncv.test()
142.

MASS lda() Fisher Linear Discriminant Analysis qda()


143. OLS ?

qr.solve()
1

qr . s o l v e (X, y )

(X 0 X)1 X 0 y
144.

R cancor()

pop < L i f e C y c l e S a v i n g s [ , 2 : 3 ]
o e c < L i f e C y c l e S a v i n g s [ ,

(2:3)]

c a n c o r ( pop , o e c )
145. R

survival
1

fit

Kaplan Meier

and

plot

it

f i t < s u r v f i t ( Surv ( time , s t a t u s ) x , data=aml )


3

plot ( f i t )
#

life

table

c b i n d ( f i t $ time , f i t $n . r i s k , f i t $n . event , f i t $ s u r v )

34

survfit type kaplan-meier,fleming-harrington, fh2

146. R

Rpad R Rpad Rpad

l i b r a r y ( Rpad )
Rpad ( )

enjoy

it

147. R SPSS

Rcmdr
Commander ( )

car effects abindlmtestmultcomprelimpRODBCrgl


148.

system.time() proc.time() R system.time() proc.time()

149. R
R maps mapdata mapdata
1

l i b r a r y ( mapdata )
map( "china" )

map
map( "state" )

maptools
PBSmapping, spatstat, maps, RArcInfo, Stata tmap, WinBUGS, Mondrian

150. Sweave
Sweave TEX S Sweave
TEX S
35

TEX
S
S

Sweave User Manual ASweave

Sweave(in R)

LAT X

Sweave TEX E pdf


dvipdfmx
151. R

gc ( )

R R
gc()
152.

TinnR RWinEdt 10 ESS(Emacs Speaks Statistics)


UltraEdit11 R Windows

10

WinEdt R RWinEdt
wordfile

11

36

Sweave

\documentclass[CJK]{cctart}
\usepackage{verbatim}
\title{Sweave }
\author{}
\date{}
\SweaveOpts{echo=FALSE}
\begin{document}
\maketitle
Sweave \LaTeX{} R
\LaTeX{}
\LaTeX{}
R $<<>>=$ $@$
echofig, R
\LaTeX{} \LaTeX{}
R \LaTeX{}
t
<<echo = TRUE>>=
require(stats)
## Students paired t-test
m <- t.test(extra group, data = sleep, paired = TRUE)
print(m)
@
R
\texttt{sleep}t
$p$-value\Sexpr{format.pval(m$p.value)}

<<echo=TRUE,results=hide>>=
choose(49,6)
@
\Sexpr{choose(49,6)}
word

37

Sweave R \LaTeX{}
\LaTeX{} \footnote{Sweave ps pdf }
Titanic

<<fig=TRUE,echo=FALSE>>=
require(graphics)
mosaicplot(Titanic, main = "Survival on the Titanic")
@
\end{document}

c
Copyright 2008
R and all the Contributors to R FAQ. All rights reserved.
c
R R FAQ 2008
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free
Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the
Invariant Sections being Contributors, no Front-Cover Texts, and no Back-Cover Texts.
GNU 1.2
Invariant Sections Contributors Front-Cover Texts Back-Cover Texts

38


Symbols

col . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 ESS . . . . . . . . . . . . . . . . . . . . . . . . . 36

\\ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 col2rgb . . . . . . . . . . . . . . . . . . . . . . 24 eval. . . . . . . . . . . . . . . . . . . . . . . . . .10


. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 colMeans . . . . . . . . . . . . . . . . . . . . 17
.packages . . . . . . . . . . . . . . . . . . . . . 6 colors . . . . . . . . . . . . . . . . . . . . . . . . 24

/ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 combn . . . . . . . . . . . . . . . . . . . . . . . 17 factanal. . . . . . . . . . . . . . . . . . . . . .30


%*% . . . . . . . . . . . . . . . . . . . . . . . . 15 Commander . . . . . . . . . . . . . . . . . 35 factorial . . . . . . . . . . . . . . . . . . . . . 17
. . . . . . . . . . . . . . . . . . . . . . . . .16, 31 complex . . . . . . . . . . . . . . . . . . . . . 16 FALSE . . . . . . . . . . . . . . . . . . . . . . 12
{} . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 confint . . . . . . . . . . . . . . . . . . . . . . . 31 file.choose. . . . . . . . . . . . . . . . . . . . .9
filled.contour . . . . . . . . . . . . . . . . 26
confint.glm . . . . . . . . . . . . . . . . . . 31
A
fivnum. . . . . . . . . . . . . . . . . . . . . . .15
confint.nls . . . . . . . . . . . . . . . . . . . 31
abline . . . . . . . . . . . . . . . . . . . . . . . 20
fix . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
contour . . . . . . . . . . . . . . . . . . . . . . 26
aggregate . . . . . . . . . . . . . . . . . . . . 13
format . . . . . . . . . . . . . . . . . . . . . . . 19
crossprod . . . . . . . . . . . . . . . . . . . . 15
any . . . . . . . . . . . . . . . . . . . . . . . . . . 11
cumsum. . . . . . . . . . . . . . . . . .12, 25
G
aov . . . . . . . . . . . . . . . . . . . . . . . . . . 31
curve . . . . . . . . . . . . . . . . . . . . . . . . 25
gc . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
aperm . . . . . . . . . . . . . . . . . . . . . . . 12
cutree . . . . . . . . . . . . . . . . . . . . . . . 30 getAnywhere. . . . . . . . . . . . . . . . . .7
append . . . . . . . . . . . . . . . . . . . . . . 10
getwd . . . . . . . . . . . . . . . . . . . . . . . . . 5
apply. . . . . . . . . . . . . . . . .12, 17, 26
D
as.Date . . . . . . . . . . . . . . . . . . . . . . 19 D . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 glm . . . . . . . . . . . . . . . . . . . . . . . . . . 32
as.numeric . . . . . . . . . . . . . . . . . . . 21 data . . . . . . . . . . . . . . . . . . . . . . . . . . 6 gray . . . . . . . . . . . . . . . . . . . . . . . . . 24
grep . . . . . . . . . . . . . . . . . . . . . . . . . 18
as.POSIXct . . . . . . . . . . . . . . . . . . 19
data frame . . . . . . . . . . . . . . . . 6, 12
grey . . . . . . . . . . . . . . . . . . . . . . . . . 24
axes . . . . . . . . . . . . . . . . . . . . . . . . . 22
demo . . . . . . . . . . . . . . . . . . . . . . . . . 3
grid . . . . . . . . . . . . . . . . . . . . . . . . . 22
axis. . . . . . . . . . . . . . . . . . . . . . . . . .22
detach . . . . . . . . . . . . . . . . . . . . . . . . 5
B

dev.copy . . . . . . . . . . . . . . . . . . . . . 25

barplot . . . . . . . . . . . . . . . . . . . . . . 24 dev.cur . . . . . . . . . . . . . . . . . . . . . . 22 hat,hatvalues . . . . . . . . . . . . . . . . 33


boxcox. . . . . . . . . . . . . . . . . . . . . . .34 dev.list . . . . . . . . . . . . . . . . . . . . . . 22 hclust . . . . . . . . . . . . . . . . . . . . . . . 29
bptest . . . . . . . . . . . . . . . . . . . . . . . 34 dev.off . . . . . . . . . . . . . . . . . . . . . . . 22 head . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Breusch-Pagan . . . . . . . . . . . . . . . 34 dev.set . . . . . . . . . . . . . . . . . . . . . . 22 heat.colors . . . . . . . . . . . . . . . . . . . 24
Devices . . . . . . . . . . . . . . . . . . . . . . 23 help . . . . . . . . . . . . . . . . . . . . . . . . . . 3
C
diag . . . . . . . . . . . . . . . . . . . . . . . . . 16 help.search. . . . . . . . . . . . . . . . . . . .3
cancor . . . . . . . . . . . . . . . . . . . . . . . 34 difftime . . . . . . . . . . . . . . . . . . . . . . 19
I
capture.output . . . . . . . . . . . . . . . . 8 duplicated . . . . . . . . . . . . . . . . . . . 12
car . . . . . . . . . . . . . . . . . . . . . . . . 7, 34 durbin.watson . . . . . . . . . . . . . . . 33 I. . . . . . . . . . . . . . . . . . . . . . . . . . . . .31
casefold . . . . . . . . . . . . . . . . . . . . . . 18 dwtest . . . . . . . . . . . . . . . . . . . . . . . 33 identical . . . . . . . . . . . . . . . . . . . . . 11
if . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

choose . . . . . . . . . . . . . . . . . . . . . . . 17
citation . . . . . . . . . . . . . . . . . . . . . . . 3

image. . . . . . . . . . . . . . . . . . . . . . . .26

clipboard . . . . . . . . . . . . . . . . . . . . . 8 edit . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 integer . . . . . . . . . . . . . . . . . . . . . . . 15


cm.colors . . . . . . . . . . . . . . . . . . . . 24 eigen . . . . . . . . . . . . . . . . . . . . . . . . 16 integrate . . . . . . . . . . . . . . . . . . . . . 15
39

iris . . . . . . . . . . . . . . . . . . . . . . . . . . 21 ncv.test . . . . . . . . . . . . . . . . . . . . . . 34

is.na . . . . . . . . . . . . . . . . . . . . . . . . . 10 NULL . . . . . . . . . . . . . . . . . . . . . . . 12 qda . . . . . . . . . . . . . . . . . . . . . . . . . . 34


is.numeric . . . . . . . . . . . . . . . . . . . 13

qqnorm . . . . . . . . . . . . . . . . . . . . . . 26
qr.solve . . . . . . . . . . . . . . . . . . . . . . 34

O
J
jarque.bera.test . . . . . . . . . . . . . . 30
jpeg . . . . . . . . . . . . . . . . . . . . . . . . . 24
K
kmeans . . . . . . . . . . . . . . . . . . . . . . 29
ks.test . . . . . . . . . . . . . . . . . . . . . . . 30

optimize . . . . . . . . . . . . . . . . . . . . . 18 Quantile Regression. . . . . . . . . .29


options . . . . . . . . . . . . . . . . . . . . . . . 4
outer . . . . . . . . . . . . . . . . . . . . . . . . 15

rainbow . . . . . . . . . . . . . . . . . . . . . 24
read.table . . . . . . . . . . . . . . . . . . . . . 8

P
Package . . . . . . . . . . . . . . . . . . . . . . .5
cluster . . . . . . . . . . . . . . . . . . 30

plotrix . . . . . . . . . . . . . . . . . . 22

latex . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Rcmdr . . . . . . . . . . . . . . . . . . 35

latex.table . . . . . . . . . . . . . . . . . . . . 9

Rpad. . . . . . . . . . . . . . . . . . . .35

layout . . . . . . . . . . . . . . . . . . . . . . . 19

rpart . . . . . . . . . . . . . . . . . . . . 33

lda . . . . . . . . . . . . . . . . . . . . . . . . . . 34

sem . . . . . . . . . . . . . . . . . . . . . 31

legend . . . . . . . . . . . . . . . . . . . . . . . 21

stats . . . . . . . . . . . . . . . . . . . . 30

letters . . . . . . . . . . . . . . . . . . . . . . . 24

tseries . . . . . . . . . . . . . . . . . . . 30

read.xls . . . . . . . . . . . . . . . . . . . . . . . 8
rect . . . . . . . . . . . . . . . . . . . . . . . . . .27
Regular Expressions . . . . . . 12, 18
rev . . . . . . . . . . . . . . . . . . . . . . . . . . 13
rgb . . . . . . . . . . . . . . . . . . . . . . . . . . 24
rm . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
RMySQL . . . . . . . . . . . . . . . . . . . . 10
rnorm . . . . . . . . . . . . . . . . 17, 22, 25
RODBC . . . . . . . . . . . . . . . . . . . . . 10

rowMeans . . . . . . . . . . . . . . . . . . . 17
Library . . . . . . . . . . . . . . . . . . . . . . . 5 par . . . . . . . . . . . . . . . . . . . 19, 22, 26
RSiteSearch. . . . . . . . . . . . . . . . . . .3
library . . . . . . . . . . . . . . . . . . . . . . . . 5 parplot . . . . . . . . . . . . . . . . . . . . . . 27
RWinEdt . . . . . . . . . . . . . . . . . . . . 36
lines . . . . . . . . . . . . . . . . . . . . . . . . . 25 parse . . . . . . . . . . . . . . . . . . . . . . . . 10
list . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 paste . . . . . . . . . . . . . . . . . . . . . . 4, 18
S
lm . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 pch . . . . . . . . . . . . . . . . . . . . . . . . . . 21
sample. . . . . . . . . . . . . . . . . . . . . . .13
lm.ridge . . . . . . . . . . . . . . . . . . . . . 32 pdf . . . . . . . . . . . . . . . . . . . . . . . . . . 24
save . . . . . . . . . . . . . . . . . . . . . . . . . . 5
lmtest . . . . . . . . . . . . . . . . . . . . . . . 34 persp . . . . . . . . . . . . . . . . . . . . . . . . 26
save.image . . . . . . . . . . . . . . . . . . . . 5
loadings . . . . . . . . . . . . . . . . . . . . . 30 pictex . . . . . . . . . . . . . . . . . . . . . . . 24
savePlot . . . . . . . . . . . . . . . . . . . . . 24
lower.tri . . . . . . . . . . . . . . . . . . . . . 16 pie . . . . . . . . . . . . . . . . . . . . . . . . . . 21
scale . . . . . . . . . . . . . . . . . . . . . . . . . 14
ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 plotmath . . . . . . . . . . . . . . . . . . . . 26
screeplot . . . . . . . . . . . . . . . . . . . . . 30
pmax . . . . . . . . . . . . . . . . . . . . . . . . 13 search . . . . . . . . . . . . . . . . . . . . . . . . 6
M
pmin . . . . . . . . . . . . . . . . . . . . . . . . 13 setwd . . . . . . . . . . . . . . . . . . . . . . . . . 5
mai . . . . . . . . . . . . . . . . . . . . . . . . . . 20
png . . . . . . . . . . . . . . . . . . . . . . . . . . 24 shapiro.test . . . . . . . . . . . . . . . . . . 30
mar . . . . . . . . . . . . . . . . . . . . . . . . . 20
points . . . . . . . . . . . . . . . . . . . . . . . 20 shell.exec . . . . . . . . . . . . . . . . . . . . . 4
matrix . . . . . . . . . . . . . . . . . . . 12, 17
poly . . . . . . . . . . . . . . . . . . . . . . . . . 32 show.error.messages . . . . . . . . . . 4
memory.limit . . . . . . . . . . . . . . . . . 4
postscript. . . . . . . . . . . . . . . . . . . .24 sink . . . . . . . . . . . . . . . . . . . . . . . . 8, 9
merge . . . . . . . . . . . . . . . . . . . . . . . 14
methods . . . . . . . . . . . . . . . . . . . . . . 7

princomp . . . . . . . . . . . . . . . . . . . . 30 solve. . . . . . . . . . . . . . . . . . . . . . . . .16


print . . . . . . . . . . . . . . . . . . . . . . . . . . 9 some . . . . . . . . . . . . . . . . . . . . . . . . . .7

proc.time . . . . . . . . . . . . . . . . . . . . 35 sort . . . . . . . . . . . . . . . . . . . . . . . . . .22

nchar . . . . . . . . . . . . . . . . . . . . . . . . 19 prompt . . . . . . . . . . . . . . . . . . . . . . . 4 source . . . . . . . . . . . . . . . . . . . . . . . . 9


40

spline . . . . . . . . . . . . . . . . . . . . . . . . 25

split.screen . . . . . . . . . . . . . . . . . . 19 t. . . . . . . . . . . . . . . . . . . . . . . . . . . . .15 unique . . . . . . . . . . . . . . . . . . . . . . . 11


sqrt. . . . . . . . . . . . . . . . . . . . . . . . . .16 t.test . . . . . . . . . . . . . . . . . . . . . . . . 29 uniroot . . . . . . . . . . . . . . . . . . . . . . 18
stars . . . . . . . . . . . . . . . . . . . . . . . . . 23 table . . . . . . . . . . . . . . . . . . . . . . . . 27 update. . . . . . . . . . . . . . . . . . . . . . .28
stem . . . . . . . . . . . . . . . . . . . . . . . . . 21 tail . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 update.packages . . . . . . . . . . . . . . 5
step . . . . . . . . . . . . . . . . . . . . . . . . . 28 tapply . . . . . . . . . . . . . . . . . . . . . . . 13 upper.tri . . . . . . . . . . . . . . . . . . . . .16
strwrap . . . . . . . . . . . . . . . . . . . . . . 22 terrain.colors . . . . . . . . . . . . . . . . 24
subset . . . . . . . . . . . . . . . . . . . . . . . 11 Tinn-R . . . . . . . . . . . . . . . . . . . . . . 36
substr . . . . . . . . . . . . . . . . . . . . . . . 18 tolower . . . . . . . . . . . . . . . . . . . . . . 18
survfit . . . . . . . . . . . . . . . . . . . . . . . 35 topo.colors. . . . . . . . . . . . . . . . . . .24
Sweave . . . . . . . . . . . . . . . . . . . . . . 35 toupper . . . . . . . . . . . . . . . . . . . . . . 18

W
windows . . . . . . . . . . . . . . . . . . . . . 24
with . . . . . . . . . . . . . . . . . . . . . . . . . 21
X

system . . . . . . . . . . . . . . . . . . . . . . . . 4 transform . . . . . . . . . . . . . . . . . . . . 12 xlsReadWrite . . . . . . . . . . . . . . . . . 8


system.time . . . . . . . . . . . . . . 17, 35 twoord.plot . . . . . . . . . . . . . . . . . . 22 xtable . . . . . . . . . . . . . . . . . . . . . . . . 9

41

You might also like