How to sample a fixed vector in R

r

#1

I want to sample the fixed vector c(2,3,4,5) 100 times .I have used the sample function like this
sample(c(2,3,4,5),100)
but I am getting error which is saying that that cannot take sample larger than population.I am not able to understand.


#2

Hi Sid,

I don’t know if I understand your questions completely. But try this -

rep( c(2,3,4,5), times = 100)

Regards,
Aayush