Hi Gundala,

try chopping off the top row like
newx<-as.matrix(x[2:dim(x)[1],])

OR

try changing it to a data frame...
new x<-data.frame(x,row.names=NULL)

#pretty sure its not row.names but there is probably an equivalent for col.names

OR

look into ?read.table and specify header = F

Cheers, Si.





----- Original Message ----- From: "Gundala Viswanath" <gunda...@gmail.com>
To: <r-h...@stat.math.ethz.ch>
Sent: Tuesday, January 06, 2009 8:14 AM
Subject: [R] Changing Matrix Header


Dear all,

I have the following matrix.

dat
        A A A A A A A A A A
   [1,] 0 0 0 0 0 0 0 0 0 0
   [2,] 0 0 0 0 0 0 0 0 0 1
   [3,] 0 0 0 0 0 0 0 0 0 2

How can I change it into:
        [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]   [,9]   [,10]
   [1,] 0     0     0      0     0     0     0     0     0       0
   [2,] 0     0     0      0     0     0     0     0     0       1
   [3,] 0     0     0      0     0     0     0     0     0        2


I tried:

as.matrix(x)

But failed.


- Gundala Viswanath
Jakarta - Indonesia

______________________________________________
R-help@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.


______________________________________________
R-help@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.

Reply via email to