An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121007/5575233d/attachment.pl>
Removing header from a matrix
4 messages · Dereje Bacha, Jeff Newmiller, David L Carlson +1 more
You need to clarify what you have and what you want. Please use the dput() function to create a reproducible example that we can enter into R to make suggestions about. [1] There are a couple of possible things that could be going on here, and what you have given so far is ambiguous. [1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity.
Dereje Bacha <d_bacha at yahoo.com> wrote:
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]] ------------------------------------------------------------------------
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
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]]
Hi, You can also do this: U1<-matrix(c(X1,X2,X3),ncol=3,nrow=2,byrow=FALSE) ?U1 #???? [,1] [,2] [,3] #[1,]?? 20?? 25?? 40 #[2,]? 100?? 90?? 80 A.K. ----- Original Message ----- From: Dereje Bacha <d_bacha at yahoo.com> To: "r-help at r-project.org" <r-help at r-project.org> Cc: Sent: Sunday, October 7, 2012 11:12 PM 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]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.