I am trying to do the following in R : get every vector of the type
c(a1, a2, ... , a10)
, where
a1 < a2 < ... < a10
, and
a1, ... , a10 in c(1:100)
.
This is possible using nested loops, with
for(a1 in 1:90) {
for(a2 in (a1+1):91) {
for(a3 in (a2+1):92) {
etc...
But you'll understand why I'd rather avoid that solution. Furthermore, I'd like to be able to make both the number of a's and their range be parametrable, so as to get, for example, (a1, a2, a3) in 1:10
Does anyone have any idea as to how I might be able to do that? Keeping in mind that I do need to go through every possible combination of (a1:a10)
, in order to be able to use the result in a later function.
Like this?
Each column is your vector. Column 1 is 1-90, column 2 is 2-91,...,column 11 is 11-100.