I want to generate vectors with all possible combinations of vector elements where a consecutive multiple occurrences of an element is considered as single occurrence of that element.
Simple cases
For n = 2,
original <- c("a","a","a","b","b","b")
v1 <- c("b","b","b","a","a","a")
So all unique occurrences of a swap with b.
For n = 3, we get
original<-c("a","a","a","b","b","b","c","c","c")
ver1<-c("a","a","a","c","c","c","b","b","b")
ver2<-c("b","b","b","a","a","a","c","c","c")
ver3<-c("b","b","b","c","c","c","a","a","a")
ver4<-c("c","c","c","b","b","b","a","a","a")
ver5<-c("c","c","c","a","a","a","b","b","b")
So all unique occurrences of a swap with b and c, all unique occurrences of b swap with a and c AND all unique occurrences of c swap with b and a.
The cases go up to n = 10. (I believe the possible vectors with different combinations are 10!)
Also, there can be more than a single chunk of a, b, c...
Complex case
For n = 2;
original<-c("a","a","a","b","b","b","a","a","b","b")
ver1<-c("b","b","b","a","a","a","b","b","a","a")
But if we swap the elements correctly the complex case and simple case should not matter.
What I am trying: (for n=2)
original<-c("a","a","a","b","b","b","a","a","b","b")
ver1<-replace(original,which(original=='a'),'b')
ver1<-replace(ver1,which(original=='b'),'a')
gives ver1<-c("b","b","b","a","a","a","b","b","a","a")
But not sure how to automate this.
