I'm doing a failure analysis, for which I like to try some different scenarios and some random trials. So far I've done this with the mosaic package and its working out great. In one specific scenario I want to generate a vector of (semi)random numbers with from different distributions. No problem so far.
Now I want to have defined number of negative numbers in this vector.
For example I want to have between 0-5 negative numbers in the vector of 25 numbers.
I thought I could use something like rbinom(n=25,prob=5/25,size=1)
to get 5 random ones first but of course 5/25, 25 times can be more than 5 ones. This seems a dead end.
I could get it done with some for loops, but probably something easier exists.
I've tried all sorts of sample,seq, shuffle combinations but I cannot get it to work so far.
does anyone have any ideas or suggestions?