Titi90
Titi90

Reputation: 139

Randomize w/no repeats using R

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

Answers (1)

Matt LaFave
Matt LaFave

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

Related Questions