R: Sample a vector with replacement multiple times

前端 未结 3 1173
时光取名叫无心
时光取名叫无心 2020-12-31 08:55

I\'d like to sample a vector x of length 7 with replacement and sample that vector 10 separate times. I\'ve tried the something like the following but can\'t get the result

3条回答
  •  暖寄归人
    2020-12-31 09:51

    This is a very convenient way to do this:

    replicate(10,sample(x,length(x),replace = TRUE))
    

提交回复
热议问题