I am just starting with R and have the following problem: given a matrix of ones and zeroes, say mdim=4 m<-matrix(round(runif(mdim^mdim)),mdim,mdim) how to construct the matrix of those rows of m, whose elements sum to 2. Contrary to the random matrix above, the actual matrix always has at least one such row. Serguei Kaniovski