Skip to content
Prev 174836 / 398502 Next

Converting a Matrix to a Vector

G'day Ken,

On Wed, 25 Mar 2009 00:13:48 -0700 (PDT)
Ken-JP <kfmfe04 at gmail.com> wrote:

            
R> tt <- reshape(data.frame(m), direction="long", varying=list(1:5), ids=rownames(m), times=colnames(m))
R> ind <- names(tt) %in% c("time", "id")
R> uu <- tt[,!ind]
R> names(uu) <- rownames(tt)
R> uu
       A.O        B.O        C.O        D.O        E.O        A.P        B.P 
0.26550866 0.37212390 0.57285336 0.90820779 0.20168193 0.89838968 0.94467527 
       C.P        D.P        E.P        A.Q        B.Q        C.Q        D.Q 
0.66079779 0.62911404 0.06178627 0.20597457 0.17655675 0.68702285 0.38410372 
       E.Q        A.R        B.R        C.R        D.R        E.R        A.S 
0.76984142 0.49769924 0.71761851 0.99190609 0.38003518 0.77744522 0.93470523 
       B.S        C.S        D.S        E.S 
0.21214252 0.65167377 0.12555510 0.26722067 

HTH.

Cheers,

	Berwin

=========================== Full address =============================
Berwin A Turlach                            Tel.: +65 6516 4416 (secr)
Dept of Statistics and Applied Probability        +65 6516 6650 (self)
Faculty of Science                          FAX : +65 6872 3919       
National University of Singapore     
6 Science Drive 2, Blk S16, Level 7          e-mail: statba at nus.edu.sg
Singapore 117546                    http://www.stat.nus.edu.sg/~statba