Displaying 3 results from an estimated 3 matches for "swaprow".
Did you mean:
swapgrow
2007 Mar 24
1
frequency tables and sorting by rowSum
...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.net/de/go/mailfooter/promail-ou...
2007 Jul 07
2
random sampling with some limitive conditions?
I want to gain thousands of random sampling data by randomizing the
presence-absence data. Meantime, one important limition is that the row and
column sums must be fixed. For example, the data "tst" is following:
site1 site2 site3 site4 site5 site6 site7 site8 1 0 0 0 1 1 0 0 0 1 1 1 0
1 0 1 1 0 0 0 1 0 1 0 0 0 0 1 0 1 0 1 1 0 1 0 0 0 0 0 0 1 0 1 1 1 1 1 1 0 0
0 0 0 0 0 0 0 0 1 0 1 0
2011 Oct 23
3
How to create a new variable based on parts of another character variable.
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111023/ae046d6a/attachment.pl>