One option is to repeat your x and prob enough for the resulting vectors to be longer than 250 elements. It's a hack, of course, but fun!
sampleWalker <- function(x, size, prob) { nx <- length(x) nrep <- 251 %/% nx + 1 sample(x = rep(x, nrep), size = size, replace = TRUE, prob = rep(prob, nrep)) } sampleWalker(1:3, 10, prob = 1:3)
source share