Description Usage Arguments Value Examples
View source: R/tidy-dist-mat.R
This function allows the user to transform a distance matrix
into a
tidy_dist_mat
matrix with information about the rows and columns in
the tidyverse
grouping style.
1 | tidy_dist_mat(dist_mat, rownames_df = NULL, colnames_df = NULL)
|
dist_mat |
distance matrix |
rownames_df |
data.frame with row identifying information |
colnames_df |
data.frame with column identifying information |
tidy_dist_mat
object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # data creation
inner_data <- data.frame(x = rnorm(3), y = rnorm(3))
my_dist_mat <- as.matrix(dist(inner_data))
rownames_df <- data.frame(id = 1:3)
colnames_df <- data.frame(id = c(1,2,1), id2 = c("f", "f", "s"))
my_tidy_dm <- tidy_dist_mat(my_dist_mat, rownames_df, colnames_df)
# visualizing the structure
print(my_tidy_dm)
# accessing structure
rownames(my_tidy_dm)
colnames(my_tidy_dm)
# updating structure
rownames(my_tidy_dm) <- colnames_df
my_tidy_dm
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.