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(cbind(p=runif(10,0,1), n=rep(1:5))) p n [1,] 0.5093493 1 [2,] 0.4947375 2 [3,] 0.6753015 3 [4,] 0.8595729 4 [5,] 0.1004739 5 [6,] 0.6292883 1 [7,] 0.3752004 2 [8,] 0.6889157 3 [9,] 0.2435880 4 [10,] 0.9619128 5 I want to create mat$x as binomial(n, p) Thanks, Robin [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.