[R] the matrix of rows with specific row sums

Rajarshi Guha rxg218 at psu.edu
Tue Nov 22 22:21:27 CET 2005


On Tue, 2005-11-22 at 16:00 -0500, Rajarshi Guha wrote:
> On Tue, 2005-11-22 at 21:55 +0100, Serguei Kaniovski wrote:
> > mdim=4
> > m<-matrix(round(runif(mdim^mdim)),mdim,mdim)
> 
> One approach:
> 
> > m
>      [,1] [,2] [,3] [,4]
> [1,]    0    0    1    0
> [2,]    0    1    1    0
> [3,]    0    0    1    1
> [4,]    0    0    0    0

Actually there was a mistake. It should read as

> > idx <- which(apply(m, 1, sum) == 2)

 
-------------------------------------------------------------------
Rajarshi Guha <rxg218 at psu.edu> <http://jijo.cjb.net>
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04 06F7 1BB9 E634 9B87 56EE
-------------------------------------------------------------------
He who is in love with himself has at least this advantage -- he won't
encounter many rivals.
-- Georg Lichtenberg, "Aphorisms"




More information about the R-help mailing list