Reputation: 139
How can randomize the following matrix without repetition of the numbers using R??
g=sample(1:28, 28), replace=T)
HW=matrix(g, ncol=4, byrow=T)
HW=as.table(HW)
HW
Upvotes: 2
Views: 12161
Reputation: 569
It looks like you're currently sampling with replacement. Turning it off should give you the behavior you want:
g = sample(1:28, 28, replace=F)
Upvotes: 7