Skip to content
Back to formatted view

Raw Message

Message-ID: <4B32711CF3EB4C49A0EDAA86752851A4@btodomain.bto.org>
Date: 2009-01-06T09:39:11Z
From: Simon Pickett
Subject: Changing Matrix Header

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


> 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 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.
>