Strange output of the `adist` fuction in R (string distance)

60 Views Asked by At

Why is output not equal to a 1 * 1 matrix here?

EDIT : the strange behaviour comes from the diag function

dist <- adist("errors", "eror", costs = c(1, 1, 1), counts = T)
dist

    [,1]
[1,]    2
attr(,"counts")
, , ins

     [,1]
[1,]    0

, , del

     [,1]
[1,]    2

, , sub

     [,1]
[1,]    0

attr(,"trafos")
     [,1]    
[1,] "MDMMMD"

# But when one element of the array is accessed, it's a 0 x 0 matrix
output <- diag(attr(dist, which = "counts")[ , , "ins"]) # or [ , , 1]
output
<0 x 0 matrix>
0

There are 0 best solutions below