next up previous index
Siguiente: Matrices. Subir: Objetos básicos Anterior: Vectores y listas   Índice de Materias


Arrays:

> x <- 1:20
> dim(x) <- c(4,5)    ## convert a vector to a 4X5 array
> x[c(2,4),]         ## print the second and the fourth row´
> x[,c(2,4)]         ## print the 2,4 columns

> x<-array(1:20, dim=c(4,5))
> x

> i<-array(c(1:3, 3:1), dim=c(3,2))
> i
> x[i]<-0           ## asigna 0 a las posiciones 1,3; 2,2;  y 3,1 de x
> x

> y<-cbind(x, nrow(x):1)  ## pega x y un vector nrow para generar y -:1 toma
etiquetas del renglon
> y<-rbind(x, ncol(x):1)  ## row-wise bind x and vector ncol(x):1


next up previous index
Siguiente: Matrices. Subir: Objetos básicos Anterior: Vectores y listas   Índice de Materias

Centro de Ciencias Genómicas/UNAM, México 2006-7