Dear all If I consider d<- c(1,2,3,4) N<- 4 n<- 2 out1<- matrix(0,N^n,n) z<-1 for(i in 1:N) { for(j in 1:N) { out1[z,1] = d[i] out1[z,2] = d[j] z<- z+1 } } library(gregmisc) out2<- permutations(N,n,d,T,T) I have that out1==out2. Ok Now, if I consider d<- c(1,2,3,4) N<- 4 n<- 3 out1<- matrix(0,N^n,n) z<-1 for(i in 1:N) { for(j in 1:N) { for(k in 1:N) { out1[z,1] = d[i] out1[z,2] = d[j] out1[z,3] = d[k] z<- z+1 } } } out2<- permutations(N,n,d,T,T) I have that out1 is not equal out1. My question is: Why out1 is not equal out2 ? Best regards
lamack lamack wrote:> > Dear all > > If I consider > > d<- c(1,2,3,4) > N<- 4 > n<- 2 > out1<- matrix(0,N^n,n) > z<-1 > > for(i in 1:N) > { > for(j in 1:N) > { > out1[z,1] = d[i] > out1[z,2] = d[j] > z<- z+1 > } > } > > library(gregmisc) > out2<- permutations(N,n,d,T,T) > > I have that out1==out2. Ok > > Now, if I consider > > d<- c(1,2,3,4) > N<- 4 > n<- 3 > out1<- matrix(0,N^n,n) > z<-1 > > for(i in 1:N) > { > for(j in 1:N) > { > for(k in 1:N) > { > out1[z,1] = d[i] > out1[z,2] = d[j] > out1[z,3] = d[k] > z<- z+1 > } > } > } > > out2<- permutations(N,n,d,T,T) > > I have that out1 is not equal out1. > > My question is: Why out1 is not equal out2 ?Because the "gregmisc" implementation of permutations() seems to be buggy (CC'ing to Greg). Uwe Ligges> Best regards > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help