Learn R Programming

yulab.utils (version 0.1.7)

mat2df: mat2df

Description

convert a matrix to a tidy data frame (from wide to long format as described in the tidyverse concept)

Usage

mat2df(x)

Value

a data.frame in long format with the 'value' column stores the original values and 'row' and 'col' columns stored in row and column index as in x

Arguments

x

the input matrix

Author

Guangchuang Yu

Examples

Run this code
x <- matrix(1:15, nrow = 3)
mat2df(x)

Run the code above in your browser using DataLab