Description Usage Arguments Value Examples
tidy_matrix
- Converts matrices into a tidy data set. Essentially, a
stacking of the matrix columns and repeating row/column names as necessary.
tidy_adjacency_matrix
- A wrapper for tidy_matrix
with the
row.name
, col.name
, & value.name
all set to
"from"
,"to"
, & "n"
, assuming preparation for network
analysis.
1 2 3 | tidy_matrix(x, row.name = "row", col.name = "col", value.name = "value", ...)
tidy_adjacency_matrix(x, ...)
|
x |
A matrix. |
row.name |
A string to use for the row names that are now a column. |
col.name |
A string to use for the column names that are now a column. |
value.name |
A string to use for the values that are now a column. |
... |
ignored. |
Returns a tidied data.frame
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | mat <- matrix(1:16, nrow = 4,
dimnames = list(LETTERS[1:4], LETTERS[23:26])
)
mat
tidy_matrix(mat)
data(simple_dtm)
tidy_matrix(as.matrix(simple_dtm), 'doc', 'term', 'n')
X <- as.matrix(simple_dtm[1:10, 1:10])
tidy_adjacency_matrix(crossprod(X))
tidy_adjacency_matrix(crossprod(t(X)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.