Skip to content

Changing Matrix Header

5 messages · Gundala Viswanath, Simon Pickett, Jorge Ivan Velez +2 more

#
Dear all,

I have the following matrix.
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:
But failed.


- Gundala Viswanath
Jakarta - Indonesia
#
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" <gundalav at gmail.com>
To: <r-help at stat.math.ethz.ch>
Sent: Tuesday, January 06, 2009 8:14 AM
Subject: [R] Changing Matrix Header
#
Hello,

colnames( dat ) <- NULL

will do the trick.

Carlos J. Gil Bellosta
http://www.datanalytics.com
On Tue, 2009-01-06 at 17:14 +0900, Gundala Viswanath wrote: