Displaying 1 result from an estimated 1 matches for "sortrowcol".
2007 Mar 24
1
frequency tables and sorting by rowSum
...gt; table(c(1,1,1,3,4,5))
1 3 4 5
3 1 1 1
, but how can i for example turn:
0 1 0
0 0 1
0 1 0
1 0 0
0 1 0
1 0 0
into
0 0 1 1
1 0 0 2
0 1 0 3
My second problem is, sorting rows and columns of a matrix by the rowSums/colSums.
I did it this way, but i think there should be a more efficient way:
sortRowCol<-function(taus) {
swaprow <- function(rsum) {
taus[(rowSums(taus)==rsum),]
}
for( i in 1:2 )
taus<-sapply(sort(rowSums(taus)),swaprow)
}
thanks in advantage, Stefan Nachtnebel
--
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: www.gmx....