[R-sig-phylo] bug in nj example

Eric Collins rec3141 at mcmaster.ca
Wed Nov 2 16:40:29 CET 2011


the matrix in the example is not symmetric, which affects the results
because the C code only uses the upper right triangle, which is wrong
in the example below.

     x <- c(7, 8, 11, 13, 16, 13, 17, 5, 8, 10, 13,
            10, 14, 5, 7, 10, 7, 11, 8, 11, 8, 12,
            5, 6, 10, 9, 13, 8)
     M <- matrix(0, 8, 8)
     M[row(M) > col(M)] <- x
     M[row(M) < col(M)] <- x

to fix:

     x <- c(7, 8, 11, 13, 16, 13, 17, 5, 8, 10, 13,
            10, 14, 5, 7, 10, 7, 11, 8, 11, 8, 12,
            5, 6, 10, 9, 13, 8)
     M <- matrix(0, 8, 8)
     M[row(M) > col(M)] <- x
     M <- t(M)

cheers,
Eric



More information about the R-sig-phylo mailing list