melt_mat: Convert an array or matrix into a long-form 'data.frame'

Description Usage Arguments Value

View source: R/melt_mat.R

Description

Useful for subsequently plotting matrices with ggplot2(). This function is a wrapper for reshape2::melt(). reshape2::melt() is used here because it nicely preserves dimnames(x) as long-form variable columns. This wrapper function simply formats the variable columns created by reshape2::melt() to play nice with ggplot2. Specifically, it reverses one factor's levels such that the diagonal of the matrix plotted by ggplot2 runs from top-left to bottom-right.

Usage

1
melt_mat(x, col = 1, ...)

Arguments

x

matrix or array

col

numeric index or name of column for which the level ordering should be reversed (defaults to 1; you will likely not need to tweak this)

...

additional optional arguments to reshape2::melt()

Value

long-form data.frame


mcfreund/mfutils documentation built on Feb. 6, 2022, 4:57 a.m.