[R] Vectorizing sample()

2008-11-07 Thread Stephen Collins
I am simulating sickness among a group of families. Part of the task is to randomly draw who in the family will be sick, randomly drawing from family ID's where Dad =1, Mom = 2, Kid1 = 3, Kid2 = 4., etc. My census of Dads is of the form shown below. Dad_ID Spouse (Y=1;N=0)

Re: [R] Vectorizing sample()

2008-11-07 Thread Duncan Murdoch
On 11/7/2008 12:00 PM, Stephen Collins wrote: I am simulating sickness among a group of families. Part of the task is to randomly draw who in the family will be sick, randomly drawing from family ID's where Dad =1, Mom = 2, Kid1 = 3, Kid2 = 4., etc. My census of Dads is of the form shown

Re: [R] Vectorizing sample()

2008-11-07 Thread Kenn Konstabel
Hi, I'm not quite sure I understood everything but is this something close? d - read.table(textConnection(Dad_ID SpouseYN NKids NSick 1 10 1 2 02 2 3 10 2 4 13 3), header=TRUE) mapply(sample,