[R] Random numbers for a group

2009-12-15 Thread Maithili Shiva
Dear R helpers I have following table Name no_of_instances    AAA                             12                                AA                               17                                A                                  0                              

Re: [R] Random numbers for a group

2009-12-15 Thread Jorge Ivan Velez
Dear Maithili, Here are two suggestions: # data set x - read.table(textConnection(Name no_of_instances AAA 12 AA17 A 0 BBB 11 BB 6 B 0 C 8 D 3), header = TRUE) closeAllConnections() x # option 1 do.call(c,with(x, tapply(no_of_instances, Name, runif))) # option 2

Re: [R] Random numbers for a group

2009-12-15 Thread Ted Harding
On 15-Dec-09 13:35:36, Jorge Ivan Velez wrote: Dear Maithili, Here are two suggestions: # data set x - read.table(textConnection(Name no_of_instances AAA 12 AA17 A 0 BBB 11 BB 6 B 0 C 8 D 3), header = TRUE) closeAllConnections() x # option 1