[R] permutations function
Uwe Ligges
ligges at statistik.uni-dortmund.de
Sat Sep 20 18:12:51 CEST 2003
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
More information about the R-help
mailing list