Skip to content
Prev 139212 / 398506 Next

Generating a new matrix using rbinom and a matrix of probabilities.

I think the following does what you want:

probMatrix <- matrix(runif(5 * 5), 5, 5)
binomialMatrix <- matrix(rbinom(5 * 5, 1, probMatrix), 5, 5)


Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
Economics Guy wrote: