I do not understand how the sample function is working if I have a vector as argument with only one element to sample from (and I just want to sample one element).
I am doing a simulation and me input vector x
is going to be of different size every time my loop runs one step. But when the vector is containing only one element, for example x = c(3)
, it should be sample 3, but I doesn't it starts to sample 2 and 1 all kind of numbers. I have tried to use set.seed
and changed the replace argument, but something is wrong. Does anyone know what's going on here?