dat2long: Melt a numeric data matrix to long format

View source: R/mt_extra_1.R

dat2longR Documentation

Melt a numeric data matrix to long format

Description

Reshape a matrix or data frame to long format with row names and column names in two columns.

Usage

dat2long(x)

Arguments

x

a matrix or data frame

Details

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.

Value

a tibble object

Examples

class(mtcars)     # data.frame
reshape2::melt(mtcars)
reshape2::melt(as.matrix(mtcars))
dat2long(mtcars)

wanchanglin/mtExtra documentation built on Aug. 2, 2024, 5:47 p.m.