dat2long | R Documentation |
Reshape a matrix or data frame to long format with row names and column names in two columns.
dat2long(x)
x |
a matrix or data frame |
reshape2::melt
keeps the rownames when melting a matrix, but
not when melting a data frame. This function keeps rownames for both
matrix and data frame.
a tibble
object
class(mtcars) # data.frame
reshape2::melt(mtcars)
reshape2::melt(as.matrix(mtcars))
dat2long(mtcars)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.