Displaying 1 result from an estimated 1 matches for "maxspac".
Did you mean:
madspaz
2012 Apr 12
1
Generate combination of strings
...ng combinations. The
below code solves my initial problem, however I would prefer not hardcoding
the positions of the 'objects' as in the future the number of 'objects'
could increase. Is there a way to loop over these objects and generate the
same output? The same goes for the 'maxspacer'.
Thanks a whole bunch!
Bart
code:
objects<-c('OCT','ASS','SUP')
maxspacer<-c(2,3)
for(x in 0:maxspacer[1]){
for(y in 0:maxspacer[2]){
combo<-c(objects[1],rep('',x),objects[2],rep('',y),objects[3])
print(combo)
}
}
--
View this message...