The command
matrix(sample.int(12, 9*12, TRUE), 9, 12)
generates an integer random matrix (9 rows and 12 columns) with integer values from 1 to 12. I wonder if there is a version of this code that generates a matrix whose rows are integer random rows with value from 1 to 12 (without repetition). I was able to find a "trivial" answer to this question; with
matrix(sample.int(m, 1*12), 9, 12,byrow=TRUE)
I obtain a matrix of this kind, but the rows are all equal to each other (this is the same row repeated 9 times).
Aucun commentaire:
Enregistrer un commentaire