Está en la página 1de 14

   

 V

   
            
             
             
              
           
          
            




                
            


                 
               
            
             





          





         







                

      
             



  V   

             
          
       


 
 





             







              

                

   










              
                 









 



&RQVROH 
5ODQJXDJH VWDQGDUG  
5ODQJXDJH KWPO  
0DQXDOV 
$SURSRV 
$ERXW 



> help() 

> help.start()           


> help(log) 

>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

               



 


  

                   




matrix(data, nrow, ncol, byrow=F)

data 
nrow 
ncol 
               
byrow




> matrix(1:12)

> m1<-matrix(1:12, nrow=4)

> m2<-matrix(1:12, ncol=4)

> 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() 



> x <- cbind(x1 = 3, x2 = c(4:1, 2:5))


> x
x1 x2
[1,] 3 4
[2,] 3 3
[3,] 3 2
[4,] 3 1
[5,] 3 2
[6,] 3 3
[7,] 3 4
[8,] 3 5
> y<-cbind(x,c(1:8))
> y
x1 x2
[1,] 3 4 1
[2,] 3 3 2
[3,] 3 2 3
[4,] 3 1 4
[5,] 3 2 5
[6,] 3 3 6
[7,] 3 4 7
[8,] 3 5 8
> apply(x, 2, sort)
x1 x2
[1,] 3 1
[2,] 3 2
[3,] 3 2
[4,] 3 3
[5,] 3 3
[6,] 3 4
[7,] 3 4
[8,] 3 5
> dimnames(x)[[1]] <- letters[1:8]
> x
x1 x2
a 3 4
b 3 3
c 3 2
d 3 1
e 3 2
f 3 3
g 3 4
h 3 5
> col.sums <- apply(x, 2, sum)
> row.sums <- apply(x, 1, sum)
> rbind(cbind(x, Rtot = row.sums), Ctot = c(col.sums, sum(col.sums)))
x1 x2 Rtot
a 3 4 7
b 3 3 6
c 3 2 5
d 3 1 4
e 3 2 5
f 3 3 6
g 3 4 7
h 3 5 8
Ctot 24 24 48

%*%*


> 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

write(x, file=data, sep=, dec=.)

write.table x file




write.table(x, file=, sep= , dec=.)

 V
   


plot()

> plot(sin, -pi, 2*pi)



> x<-seq(-3,3,0.01)

> plot(x,dnorm(x),type="p",col=2,main="Densidad N(0,1)")

  type             
(p, lb
        col   main      


lines()points()


> lines(x,dnorm(x,1),col=3)

 V

;


{comando1; comando2; comando3; ...}

  

if

if (expr_1) expr_2 else expr_3

 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

for (nombre in expr_1) {expr_2}

 nombre         expr_1      
m:nexpr_2



> for(i in 1:10) {print(i)}

while

while (condicion) {expr}

exprcondicin



> n<-1
> while (n<=10) {print(n);n=n+1}

              
while

   

               


nombre <- function (arg_1 , arg_2, .....) expr

nombrearg_1arg_2
comandos







nombre <- function(arg_1, arg_2=val, ...) expr

              


> media2<-function(x,y){return((x+y)/2)}

> media2(10,20)

return
     return     




 

 



   



>library(Rcmdr) 




               










           

           


 
           


 
           
          

 
 
 






 D      
D       

 /    /
W     W       

 


W       W
              
 




                



              



             




También podría gustarte