I'm looking to generate a random number sequence with 14 numbers between 1 & 25 (inclusive). Which I can do in R using > sample (1:25, 14)
. However, for some of the sequences I need certain numbers excluded (2,3,4,5,6,16,21,etc.). I also need to make sure certain numbers don't fall within the first 4 numbers of the sequences (i.e.1-6, 16, 21,etc.) I also need certain sequences where certain numbers appear twice between the 5th and 14th position.
Sorry if it's not clear, but I basically need a random number sequence generator in R which
- includes exclusion criteria
- specifies what position certain numbers appear in
- allows for certain number to appear twice in the sequence after a certain position.
If anyone knows of function that could do this I'd be very grateful.
c
and multiple calls tosample
and you're all set. Any function that achieves your desired result will just be a combination of those two functions (and maybesort
and some indexing). – Thomas