View source: R/matrix_to_data_frame.R
matrixToDataFrame | R Documentation |
Convert a Matrix to a Data Frame (in "Long" Format)
matrixToDataFrame(
x,
name_row = NULL,
name_column = NULL,
name_value = "value",
row_first = TRUE
)
x |
matrix |
name_row |
name to be given to the data frame column containing the
row "coordinates". Default: |
name_column |
name to be given to the data frame column containing the
column "coordinates". Default: |
name_value |
name to be given to the data frame column containing the
matrix values. Default: |
row_first |
if |
data frame with three columns: 1. row "coordinate", 2. column "coordinate", 3. value
m1 <- matrix(1:12, nrow = 3, dimnames = list(NULL, letters[1:4]))
m2 <- matrix(1:12, nrow = 3, dimnames = list(index = NULL, letters[1:4]))
m3 <- matrix(1:12, nrow = 3, dimnames = list(NULL, letter = letters[1:4]))
matrixToDataFrame(x = m1)
matrixToDataFrame(x = m1, row_first = FALSE)
matrixToDataFrame(x = m2)
matrixToDataFrame(x = m3)
matrixToDataFrame(x = m3, "myrow", "mycol", "myval")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.