Skip to content

breaking up n object into random groups

3 messages · statfan, David Winsemius, Bert Gunter

#
On Dec 2, 2011, at 10:09 AM, statfan wrote:

            
Try assigning with a sample() from:

unlist(mapply(rep, c(1:4), each=c(n1,n2,n3,n4)))
#
There are a million ways to do this, probably.

brks <- c(1,sort(sample(seq_len(99),3)),100)  ##  4 random groups

and then use brks as the breaks parameter in cut() with include.lowest = TRUE

?cut

-- Bert
On Fri, Dec 2, 2011 at 7:09 AM, statfan <irene_vrbik at hotmail.com> wrote: