search for: sumrow

Displaying 3 results from an estimated 3 matches for "sumrow".

2011 Nov 21
4
Discarding a matrix based on the rowSums value
...0 0 0 0 0 [10,] 0 1 0 1 0 1 1 0 0 1 must be discarded. For any N.1s <= Nrow, I am trying Nrow = 10 Ncol = 10 N.1s = 5 flag <- TRUE while (flag == TRUE) { m <- matrix ((sample (c(rep(1, each=N.1s), rep(0, each=((Ncol*Nrow)-N.1s))))), Nrow) SUMROW <- rowSums(m) if (SUMROW == N.1s) {flag <- TRUE} else {flag <- FALSE} } } but I get this warning Warning message: In if (SUMROW == N.1s) { : the condition has length > 1 and only the first element will be used What I specifically need is a way to write "If any of the elements...
2012 Dec 17
2
Why does matrix selection behave differently when using which?
...greater than the number of rows in "t". The table "t" I use can be downloaded from here: https://github.com/groupschoof/PhyloFun/archive/test_selector.zip Unzip the file and read in the table "t" using t <- read.table("test.tbl") The above function "sumRows" is defined as follows: sumRows <- function( tbl, ps ) { sum( sapply(ps, function(x) { t <- if ( is.na(x) ) { tbl[ which( is.na(tbl[ , "Domain.Architecture.Distance" ]) ), , drop=F] } else { tbl[ which( tbl[ , "Domain.Archit...
2010 Oct 20
2
rowsum
...rom adding up: [11 + 31 + 16 + 6 + 10 + 13 + 10 + 25 + 2] 52 59 38 52 97 75 57 1 64 #From adding up: [14 +13 +14 +23] 57 114 12 57 06 26 Now, I now it should be possible to first separate the data in two sets, where DF1 <- DF0[DF0$B != 1,] DF2 <- DF0[DF0$B == 1,] Then I should apply sumrow to DF2 with some "group" vector, but I do not know where to go from here. Can anyone help? Thanks in advance! -- View this message in context: http://r.789695.n4.nabble.com/rowsum-tp3003551p3003551.html Sent from the R help mailing list archive at Nabble.com.