powered by
Tidy a distance matrix, such as that computed by the dist function, into a one-row-per-pair table. If the distance matrix does not include an upper triangle and/or diagonal, this will not either.
# S3 method for dist tidy(x, diag = attr(x, "Diag"), upper = attr(x, "Upper"), ...)
A "dist" object
Whether to include the diagonal of the distance matrix. Defaults to whether the distance matrix includes it
Whether to include the upper right triangle of the distance matrix. Defaults to whether the distance matrix includes it
Extra arguments, not used
A data frame with one row for each pair of item distances, with columns:
First item
Second item
Distance between items
# NOT RUN { iris_dist <- dist(t(iris[, 1:4])) iris_dist tidy(iris_dist) tidy(iris_dist, upper = TRUE) tidy(iris_dist, diag = TRUE) # }
Run the code above in your browser using DataLab