Re: [R] Alternatives to unlist()

2007-05-04 Thread Sundar Dorai-Raj
Jacques Wagnor said the following on 5/4/2007 8:53 AM: > Given the following, one of the things I am trying to see is what % of > draws are below a certain number: > > lambda <- 3 > rate <- 5 > n <- 5 > > set.seed(123) > v <- replicate(n, rexp(rpois(1,lambda), rate)) > vv <- unlist(v) > cat("%

Re: [R] Alternatives to unlist()

2007-05-04 Thread Prof Brian Ripley
First, your example works happily in a 1Gb Windows machine under R 2.5.0: your R (2.2.1) is well overdue for an update. What you are generating is a random number of rexp(rate=10) random variables. So all you need is n <- 100 N <- sum (rpois(n, 26)) vv <- rexp(N, 10) mean(vv[vv < 0.1]) whi

[R] Alternatives to unlist()

2007-05-04 Thread Jacques Wagnor
Given the following, one of the things I am trying to see is what % of draws are below a certain number: lambda <- 3 rate <- 5 n <- 5 set.seed(123) v <- replicate(n, rexp(rpois(1,lambda), rate)) vv <- unlist(v) cat("% of draws below 0.1:", round(length(subset(vv, vv < 0.1))/length(vv)*100,0), "%\