I'm trying to split a vector (that is changing eveytime) into chunks, however same values have to belong to the same chunk. The number of chunks can vary but can be at least 4, or that the chunks are of equal frequencies.
For example, here is a vector:
j = c(1 ,11, 1, 2, 1, 1, 1 ,2, 4, 6 ,3)
the chunks using chunk(x=sort(j),n=4)
will give
$`1`
[1] 1 1 1
$`2`
[1] 1 1 2
$`3`
[1] 2 3
$`4`
[1] 4 6 11
what i want is to have
$`1`
[1] 1 1 1 1 1
$`2`
[1] 2 2 3
$`3`
[1] 4 6
$`4`
[1] 11