All suggestions dealt with either sample or cut (which I had previously
tried).
Christian Keller's suggestion using sample was to use sample to generate
a multinomial sample by :
codes <- 1:5 # assume the feeding sites are coded as 1,2,3,4,5
probs <- c(.25, .35, .4, 0, 0) # the probabilities for codes
sample(codes, replace=T, size=20, prob=probs)
Tony Plate's suggestion was to use cut in the following manner :
> probs <- c(.25, .35, .4, 0, 0)
> sites <- cut(runif(20),c(0,cumsum(probs)),inc=T)
> sites
[1] 2 1 3 1 1 2 3 3 3 2 1 3 2 2 3 2 1 2 3 2
Each of the approaches presented provided a solution to my problem.
Thanks to all who responded
Peter Scherer
Dow AgroSciences
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news