[R] Removing header from a matrix

David L Carlson dcarlson at tamu.edu
Mon Oct 8 06:19:54 CEST 2012


These are just column names, but if you want to remove them, it is easy:

> X1 <- c(20, 100)
> X2 <- c(25, 90)
> X3 <- c(40, 80)
> U <- cbind(X1, X2, X3)
> U
      X1 X2 X3
[1,]  20 25 40
[2,] 100 90 80
> colnames(U) <- NULL
> U
     [,1] [,2] [,3]
[1,]   20   25   40
[2,]  100   90   80


----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Dereje Bacha
> Sent: Sunday, October 07, 2012 10:13 PM
> To: r-help at r-project.org
> Subject: [R] Removing header from a matrix
> 
> I have three column vectors (X1, X2, X3).
>         X1  X2  X3
>        20   25  40
>        100 90  80
> I want to put them as one matrix of dimention 2 by 3,  but remove
> headers(X1,X2,X3) from the matrix. I wrote
> as follows
> 
> U<-cbind (X1,X2,X3)
> 
> the headers are there. I need help please. Thanks
> Dereje
> 	[[alternative HTML version deleted]]




More information about the R-help mailing list