Is there any function can solve this kind of different-sized random resampling problem? For example, given a vector, data = c('a','a','b','c','d','e')
. I want to randomly resample this vector into 3 groups with different sizes 1 ,3 ,2 respectively. Like
input: samplefunc(data,size = c(1,3,2))
output: c('a') c('a','d','e') c('b','c')
I only found this "sample" function, but it is only for one size sample:
sample(x, size, replace = FALSE, prob = NULL)
size: a non-negative integer giving the number of items to choose.
Since I have to divide the data into many groups(not just 3), if there is an existed function can do that, it will be much easier without the for-loop.