Re: [R] generate multiple probability distributions

2013-12-02 Thread Michael Friendly
On 12/2/2013 10:12 AM, Duncan Murdoch wrote: dbinom can take vector inputs for the parameters, so this would be a bit simpler: x <- seq(0,12) x <- rep(x, 4) p <- rep(c(1/6, 1/3, 1/2, 2/3), each=13) bin.df <- data.frame(x, prob = dbinom(x, 12, p), p) Thanks, Duncan What I was missing was how

Re: [R] generate multiple probability distributions

2013-12-02 Thread David Carlson
You can use recycling to simplify things: > set.seed(42) > x <- seq(0,12) > bin.df <- as.data.frame( + rbind( cbind(x, prob=dbinom(x,12,1/6), p=1/6), +cbind(x, prob=dbinom(x,12,1/3), p=1/3), +cbind(x, prob=dbinom(x,12,1/2), p=1/2), +cbind(x, prob=dbinom(x,12

Re: [R] generate multiple probability distributions

2013-12-02 Thread Duncan Murdoch
On 02/12/2013 9:47 AM, Michael Friendly wrote: I want to generate a collection of probability distributions in a data frame, with varying parameters. There must be some simpler way than what I have below (avoiding rbind and cbind), but I can't quite see it. x <- seq(0,12) bin.df <- as.data.fram