How can I find out how many rows of a matrix satisfy a rather complicated criterion (in R)?
- by Brani
As an example, here is a way to get a matrix of all possible outcomes of rolling 4 (fair) dice.
z <- as.matrix(expand.grid(c(1:6),c(1:6),c(1:6),c(1:6)))
As you may already have understood, I'm trying to work out a question that was closed, though, in my opinion, it's a challenging one. I used counting techniques to solve it (I mean by hand) and I finaly arrived to a number of outcomes, with a sum of subset being 5, equal to 1083 out of 1296. That result is consistent with the answers provided to that question, before it was closed. I was wondering how could that subset of outcomes (say z1, where dim(z1) = [1083,4] ) be generated using R. Do you have any ideas?
Thank you.