Re: [R] Generation of binomial numbers using a loop

2010-06-23 Thread Phil Spector
Sarah - If you're willing to forgo the loop, res = unlist(mapply(rbinom,frequency,no_trials,prob)) res[res == 0] = 1 will give you what you want. - Phil Spector Statistical Computing Facility

[R] Generation of binomial numbers using a loop

2010-06-23 Thread Sarah Sanchez
Dea'R' helpers I have following data - prob = c(0.1, 0.2, 0.3, 0.4, 0.5) frequency = c(100, 75, 45, 30, 25) no_trials = c(10, 8, 6, 4, 2) freq1 = rbinom(frequency[1], no_trials[1], prob[1]) freq2 = rbinom(frequency[2], no_trials[2], prob[2]) freq3 = rbinom(frequency[3], no_trials[3], prob[3])