say n = 100
I want to partition this into 4 random groups wheren n1 + n2 + n3 + n4 = n
and ni is the number of elements in group i.
Thank you for you help
--
View this message in context:
http://r.789695.n4.nabble.com/breaking-up-n-object-into-random-groups-tp4147476p4147476.html
Sent from the
On Dec 2, 2011, at 10:09 AM, statfan wrote:
say n = 100
I want to partition this into 4 random groups wheren n1 + n2 + n3 +
n4 = n
and ni is the number of elements in group i.
Try assigning with a sample() from:
unlist(mapply(rep, c(1:4), each=c(n1,n2,n3,n4)))
--
David Winsemius, MD
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_vr...@hotmail.com wrote:
say n = 100
I
3 matches
Mail list logo