tidy_dist_mat: tidy_dist_mat objects

Description Usage Arguments Value Examples

View source: R/tidy-dist-mat.R

Description

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.

Usage

1
tidy_dist_mat(dist_mat, rownames_df = NULL, colnames_df = NULL)

Arguments

dist_mat

distance matrix

rownames_df

data.frame with row identifying information

colnames_df

data.frame with column identifying information

Value

tidy_dist_mat object

Examples

 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

skgallagher/EpiCompare documentation built on Sept. 14, 2021, 5:45 a.m.