Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Manual Programa R
Manual Programa R
V
&RQVROH
5ODQJXDJHVWDQGDUG
5ODQJXDJHKWPO
0DQXDOV
$SURSRV
$ERXW
> help.start()
>apropos(plot)
>help.search(plot)
A
%%
%/%
*
+
-
^
/
<
<=
>
>=
==
!=
exp(x)
log(x)
log(x,n)
log10(x)
sqrt(x)
factorial(x)
floor(x)
ceiling(x)
trunc(x)
round(x, digits=0)
signif(x, digits=6)
cos(x)
sin(x)
tan(x)
acos(x),asin(x),atan(x)
abs(x)
<-
(.)
_
logic TRUE (T)FALSE (F)
numeric
integer
double
complex
character
NA
NaN
> c(1,2,3,4,5)
[1] 1 2 3 4 5
> c(T,F,T,T)
[1] TRUE FALSE TRUE TRUE
> x<-c("Badajoz","Cceres")
> x
[1] "Badajoz" "Cceres"
> c(1,2,3,"cuatro")->x
> x
[1] "1" "2" "3" "cuatro"
> c(1,2,3,F)
[1] 1 2 3 0
c()
> x<-c(1,3,5)
> y<-c(2,4,6)
> c(x,y)
[1] 1 3 5 2 4 6
> x<-c(1,2,3,4,5,6,7,8,9,10);x[3];x[-3];x[c(1,5,7)]
[1] 3
[1] 1 2 4 5 6 7 8 9 10
[1] 1 5 7
> x>8
[1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE TRUE
>1:5
[1] 1 2 3 4 5
>seq(1,6)
[1] 1 2 3 4 5 6
> seq(1,6,by=0.5)
[1] 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0
> seq(1,6,length=10)
[1] 1.000000 1.555556 2.111111 2.666667 3.222222 3.777778 4.333333
4.888889
[9] 5.444444 6.000000
> rep(1,5)
[1] 1 1 1 1 1
> rep(c(1,2),5)
[1] 1 2 1 2 1 2 1 2 1 2
> rep(1:4,2)
[1] 1 2 3 4 1 2 3 4
> rep(1:3,c(1,4,5))
[1] 1 2 2 2 2 3 3 3 3 3
data
nrow
ncol
byrow
> matrix(1:12)
> matrix(c(1,2,3,4,5,6,7,8,9,10,11,12),ncol=4,nrow=3)
> matrix(c(1,2,3,4,5,6,7,8,9,10,11,12),ncol=4,nrow=3,byrow=T)
dim()
dimnames()
colnames()
rownames()
mode()
length()
is.matrix()
[ , ]
apply()
cbind()
rbind()
t()
%*%*
> m1%*%m2
[,1] [,2] [,3] [,4]
[1,] 38 83 128 173
[2,] 44 98 152 206
[3,] 50 113 176 239
[4,] 56 128 200 272
array(data, dim=length(data))
datadim
>array(1:3,c(2,4))
[,1] [,2] [,3] [,4]
[1,] 1 3 2 1
[2,] 2 1 3 2
dimnames, dim, nrow
data.frame( )
read.table( )
V
scan( )
>scan(datos)
>scan()
1: 1
2: 2
3: 3
4:
Read 3 items
[1] 1 2 3
read.table
read.table(file, head=T)
.
head=T
>read.table(datos.dat,sep=,)
>library(car)
car
>data()
>data(nombre)
>ls()
xfilewrite
V
plot()
> x<-seq(-3,3,0.01)
type
(p, lb
col main
lines()points()
> lines(x,dnorm(x,1),col=3)
V
;
if
expr_1
expr_2 expr_3.
> n <- 10
> pares <- c()
> impares <- c()
> for(i in 1:n){ if(i%%2==0) pares<-c(pares,i) else impares<-
c(impares,i)}
> pares
[1] 2 4 6 8 10
> impares
[1] 1 3 5 7 9
for
nombre expr_1
m:nexpr_2
while
exprcondicin
> n<-1
> while (n<=10) {print(n);n=n+1}
while
nombrearg_1arg_2
comandos
> media2<-function(x,y){return((x+y)/2)}
> media2(10,20)
return
return
>library(Rcmdr)
D
D
/ /
W W
W W