How do I create a matrix in R with 50 individuals having labels K=1,2,3 and then all possible outcomes? It does not seem to be either combinations or per muations. So as an example with N=2 the following, only then not 2 rows but 50. So I get a 50x3^50 matrix.
> cbind(c(1,1),c(1,2),c(1,3),c(2,1),c(2,2),c(2,3),c(3,1),c(3,2),c(3,3))
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,]    1    1    1    2    2    2    3    3    3
[2,]    1    2    3    1    2    3    1    2    3
And for N=3:
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25] [,26] [,27]
[1,]    1    1    1    1    1    1    1    1    1     2     2     2     2     2     2     2     2     2     3     3     3     3     3     3     3     3     3
[2,]    1    1    1    2    2    2    3    3    3     1     1     1     2     2     2     3     3     3     1     1     1     2     2     2     3     3     3
[3,]    1    2    3    1    2    3    1    2    3     1     2     3     1     2     3     1     2     3     1     2     3     1     2     3     1     2     3