[R] question about transpose

David Winsemius dwinsemius at comcast.net
Sat Jan 30 02:18:49 CET 2010


On Jan 29, 2010, at 6:58 PM, Zoppoli, Gabriele (NIH/NCI) [G] wrote:

> Hi all,
>
> if I transpose a matrix with t(data), the newly created colums do  
> not appear to have the first row as header. How can I do to have all  
> the newly created columns have their first row as a header?

The term "header" doesn't really have meaning in R with reference to  
matrices. And the analog that might make sense, column names, fails to  
behave in the manner of your complaint.


 > M <- matrix(1:9, 3,3)
 > colnames(M) <- letters[1:3]
 > M
      a b c
[1,] 1 4 7
[2,] 2 5 8
[3,] 3 6 9
 > t(M)
   [,1] [,2] [,3]
a    1    2    3
b    4    5    6
c    7    8    9

So exactly _what_ is your problem?

-- 
David.


>
> Thanks
>
>
> Gabriele Zoppoli, MD
> Ph.D. Fellow, Experimental and Clinical Oncology and Hematology,  
> University of Genova, Genova, Italy
> Guest Researcher, LMP, NCI, NIH, Bethesda MD
>
> Work: 301-451-8575
> Mobile: 301-204-5642
> Email: zoppolig at mail.nih.gov
> ______________________________________________
> 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-help mailing list