Re: [R] simple apply syntax

2010-07-11 Thread Prof Brian Ripley
On Sun, 11 Jul 2010, Robin Jeffries wrote: I know this is a simple question, but I have yet to master the apply statements. Any help would be appreciated. You don't want to use apply() here: rbinom is vectorized. However, you cannot use mat$x on a matrix, and the cbind() gave you a matrix an

Re: [R] simple apply syntax

2010-07-11 Thread Joshua Wiley
Hello Robin, I cannot quite figure out what your final goal is (it's late and I'm low on caffeine so if I missed the obvious, bear with me). I think you may mean the rbinom() function rather than the binomial() function (see ?rbinom and ?binomial, respectively). At any rate, this should get you

[R] simple apply syntax

2010-07-11 Thread Robin Jeffries
I know this is a simple question, but I have yet to master the apply statements. Any help would be appreciated. I have a column of probabilities and sample sizes, I would like to create a column of binomial random variables using those corresponding probabilities. Eg. mat = as.matrix(cbi