[R] Setting max values for rpois

Bret Collier bacolli at uark.edu
Wed May 12 23:11:08 CEST 2004


R-users,
         I am simulating a birth process for 4 classes of individuals with 
l[i] being the average No. fetuses per individual.  However, I need to 
bound the resulting values for each generated rpois to be <=3 (no 
individual can have > 3 offspring).  I have not been able to figure out how 
to incorporate this into the below example.  Any suggestions on integrating 
would be appreciated.


recruit.f <- c(12, 12, 25, 51)  #No. females in each age class
l <- c(.05, 1.22, 1.6, 1.8)  #mean No. fetuses for each age class
x <- sapply(lapply(1:4, function(i) rpois(recruit.f[i], l[i])), sum)

TIA,

Bret A. Collier
Arkansas Cooperative Fish and Wildlife Research Unit
University of Arkansas




More information about the R-help mailing list