### binary data
x <- matrix(sample(c(FALSE,TRUE),8,rep=TRUE), ncol=2)
dists(x, method="binary")
### for real-valued data
dists(x, method="ebinary")
### for positive real-valued data
dists(x, method="fbinary")
### cross distances
dists(x, x, method="binary")
### this is the same but less efficient
as.matrix(dists(x, method="binary"))
## test inheritance of names
rownames(x) <- LETTERS[1:4]
dists(x)
dists(x,x)
## custom distance function
f <- function(x, y) sum(x*y)
dapply(x, FUN=f)
dapply(x,x, FUN=f)
## working with lists
z <- unlist(apply(x, 1, list), recursive = FALSE)
dapply.list(z, FUN=f)
dapply.list(z, z, FUN=f)
Run the code above in your browser using DataLab