Converts the active metadata component (row_data or col_data) to a tibble. This method only works when rows or columns are active, not when the matrix is active.
Usage
# S3 method for class 'tidymatrix'
as_tibble(x, ...)Examples
mat <- matrix(rnorm(100), nrow = 10, ncol = 10)
row_data <- data.frame(id = 1:10, group = rep(c("A", "B"), each = 5))
tm <- tidymatrix(mat, row_data)
# Convert row metadata to a tibble, e.g. for plotting
pcs <- tm |>
activate(rows) |>
compute_prcomp(center = TRUE, scale. = TRUE) |>
as_tibble()
if (requireNamespace("ggplot2", quietly = TRUE)) {
library(ggplot2)
ggplot(pcs, aes(x = row_pca_PC1, y = row_pca_PC2, color = group)) +
geom_point()
}