[R] the matrix of rows with specific row sums

Serguei Kaniovski kaniovsk at wsr.ac.at
Tue Nov 22 21:55:28 CET 2005


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




More information about the R-help mailing list