Hi r-help-boun...@r-project.org napsal dne 28.01.2010 06:21:40:
> > i have a simple question. If i have a 2x2 matrix with [,1] and [,2] i want to > test each of these to see if they are below some number. If each component > in column is below the number then it returns a 1. Now from this result I > would like to add the number of 1's that came up. How can i do this? Something like that? mat <- matrix(rnorm(4),2,2) mat [,1] [,2] [1,] -0.08882795 0.0567098 [2,] 0.13091031 -0.1269901 mat<0 [,1] [,2] [1,] TRUE FALSE [2,] FALSE TRUE colSums(mat<0) [1] 1 1 Regards Petr > -- > View this message in context: http://n4.nabble.com/If-then-test-tp1322119p1322119.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.