| matrix_to_long | R Documentation | 
Returns a data.table in long form, such that it is suitable for use in mutual_total, etc. Colnames and rownames of the matrix will be respected.
matrix_to_long(
  matrix,
  group = "group",
  unit = "unit",
  weight = "n",
  drop_zero = TRUE
)
| matrix | A matrix, where the rows represent the units, and the column represent the groups. | 
| group | Variable name for group. (Default  | 
| unit | Variable name for unit. (Default  | 
| weight | Variable name for frequency weight. (Default  | 
| drop_zero | Drop unit-group combinations with zero weight. (Default  | 
A data.table.
m <- matrix(c(10, 20, 30, 30, 20, 10), nrow = 3)
colnames(m) <- c("Black", "White")
long <- matrix_to_long(m, group = "race", unit = "school")
mutual_total(long, "race", "school", weight = "n")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.