matWide2Long: Reformat

View source: R/misc.R

matWide2LongR Documentation

Reformat

Description

Reformats the upper triangular part (and, optionally, the diagonal) of a matrix from the wide format into the long format.

Usage

matWide2Long(
  mat,
  diag = TRUE,
  outColNs = c("row", "col", "val"),
  stringsAsFactors = FALSE
)

Arguments

mat

matrix

diag

if FALSE, the diagonal entries will be ignored

outColNs

names of the columns in the output

stringsAsFactors

if TRUE, character vectors will be converted to factors

Value

data frame

Author(s)

Zheyuan Li [aut] (https://stackoverflow.com/a/41745373/597069), Timothee Flutre [ctb]


timflutre/rutilstimflutre documentation built on Feb. 12, 2025, 11:35 p.m.